mangstadt / biweekly

biweekly is an iCalendar library written in Java.
BSD 2-Clause "Simplified" License
320 stars 44 forks source link

Validating RRULE strings #124

Open mangstadt opened 1 year ago

mangstadt commented 1 year ago

From jordiperezg on Gitter (link):

Hello Mangstadt! I'm parsing a string recurrence rule in the way you describe in the FAQ. My question is if it is possible to validate the rule being parsed. I just realized that parsing an invalid rule, such as "INVALID", will work, and yet if I use the date iterator to get the next execution date, it will return a date a year from now, as if the recurrence were YEARLY. Is this the correct behavior? PD. I'm just using the library to get the next execution from a recurrence rule.

mangstadt commented 1 year ago

Such a recurrence rule will treat the input value as an unrecognized key/value field ("x-rule") and have a null or empty values for all of its fields. The date iterator is acting like the recurrence is YEARLY because that is the default frequency which is used if the recurrence object has no frequency defined.