Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for RRULE validity checker #47

Open
YanTheFawn opened this issue May 4, 2022 · 0 comments
Open

Request for RRULE validity checker #47

YanTheFawn opened this issue May 4, 2022 · 0 comments

Comments

@YanTheFawn
Copy link

Hey guys, would love it if there was a utility method in this library to check the validity of an rrule.

e.g.
RruleValidator.validate("FREQ=DAILY;INTERVAL=1") => true
RruleValidator.validate("FREQ=SNAILY;INTERVAL=toucan_sam") => false

Thoughts?

leoarnold added a commit to leoarnold/ruby-rrule that referenced this issue Jul 4, 2022
Closes square#46. Fixes square#47.

Prior to this commit the gem failed to validate the RRULE's syntax:

* If a keyword was misspelled, it would *silently* be ignored
* If a keyword appeared multiple times only the last occurance was used
* If the mutually exclusive keywords COUNT and UNTIL were used together
  then no exception was raised

```ruby
> rrule = RRule.parse('FREQ=DAILY;COUNT=3;COUNT=7;UNTIL=20200302;INTERVALLLLL=9')
 => #<RRule::Rule:0x000055db33885018 ...
> rrule.instance_variable_get(:@options)
 => {:interval=>1, :wkst=>1, :freq=>"DAILY", :count=>7, :until=>2020-03-02 00:00:00 +0100, ...
```

Therefore we add a validating parser with comprehensive error messages:

```ruby
> rrule = RRule.parse('FREQ=DAILY;COUNT=3;COUNT=7;UNTIL=20200302;INTERVALLLLL=9')
Traceback (most recent call last):
...
RRule::InvalidRRule (SyntaxError)

* unknown keyword 'INTERVALLLLL' at position 42:

        'FREQ=DAILY;COUNT=3;COUNT=7;UNTIL=20200302;INTERVALLLLL=9'
                                                   ^^^^^^^^^^^^
* keyword 'COUNT' appeared more than once at positions 11 and 19:

        'FREQ=DAILY;COUNT=3;COUNT=7;UNTIL=20200302;INTERVALLLLL=9'
                    ^^^^^   ^^^^^
* keywords 'COUNT' and 'UNTIL' are mutually exclusive at positions 11, 19 and 27:

        'FREQ=DAILY;COUNT=3;COUNT=7;UNTIL=20200302;INTERVALLLLL=9'
                    ^^^^^   ^^^^^   ^^^^^
```
leoarnold added a commit to leoarnold/ruby-rrule that referenced this issue Jul 4, 2022
Closes square#46. Fixes square#47.

Prior to this commit the gem failed to validate the RRULE's syntax:

* If a keyword was misspelled, it would *silently* be ignored
* If a keyword appeared multiple times only the last occurance was used
* If the mutually exclusive keywords COUNT and UNTIL were used together
  then no exception was raised

```ruby
> rrule = RRule.parse('FREQ=DAILY;COUNT=3;COUNT=7;UNTIL=20200302;INTERVALLLLL=9')
 => #<RRule::Rule:0x000055db33885018 ...
> rrule.instance_variable_get(:@options)
 => {:interval=>1, :wkst=>1, :freq=>"DAILY", :count=>7, :until=>2020-03-02 00:00:00 +0100, ...
```

Therefore we add a validating parser with comprehensive error messages:

```ruby
> rrule = RRule.parse('FREQ=DAILY;COUNT=3;COUNT=7;UNTIL=20200302;INTERVALLLLL=9')
Traceback (most recent call last):
...
RRule::InvalidRRule (SyntaxError)

* unknown keyword 'INTERVALLLLL' at position 42:

        'FREQ=DAILY;COUNT=3;COUNT=7;UNTIL=20200302;INTERVALLLLL=9'
                                                   ^^^^^^^^^^^^
* keyword 'COUNT' appeared more than once at positions 11 and 19:

        'FREQ=DAILY;COUNT=3;COUNT=7;UNTIL=20200302;INTERVALLLLL=9'
                    ^^^^^   ^^^^^
* keywords 'COUNT' and 'UNTIL' are mutually exclusive at positions 11, 19 and 27:

        'FREQ=DAILY;COUNT=3;COUNT=7;UNTIL=20200302;INTERVALLLLL=9'
                    ^^^^^   ^^^^^   ^^^^^
```
leoarnold added a commit to leoarnold/ruby-rrule that referenced this issue Jul 4, 2022
Closes square#46. Fixes square#47.

Prior to this commit the gem failed to validate the RRULE's syntax:

* If a keyword was misspelled, it would *silently* be ignored
* If a keyword appeared multiple times only the last occurance was used
* If the mutually exclusive keywords COUNT and UNTIL were used together
  then no exception was raised

```ruby
> rrule = RRule.parse('FREQ=DAILY;COUNT=3;COUNT=7;UNTIL=20200302;INTERVALLLLL=9')
 => #<RRule::Rule:0x000055db33885018 ...
> rrule.instance_variable_get(:@options)
 => {:interval=>1, :wkst=>1, :freq=>"DAILY", :count=>7, :until=>2020-03-02 00:00:00 +0100, ...
```

Therefore we add a validating parser with comprehensive error messages:

```ruby
> rrule = RRule.parse('FREQ=DAILY;COUNT=3;COUNT=7;UNTIL=20200302;INTERVALLLLL=9')
Traceback (most recent call last):
...
RRule::InvalidRRule (SyntaxError)

* unknown keyword 'INTERVALLLLL' at position 42:

        'FREQ=DAILY;COUNT=3;COUNT=7;UNTIL=20200302;INTERVALLLLL=9'
                                                   ^^^^^^^^^^^^
* keyword 'COUNT' appeared more than once at positions 11 and 19:

        'FREQ=DAILY;COUNT=3;COUNT=7;UNTIL=20200302;INTERVALLLLL=9'
                    ^^^^^   ^^^^^
* keywords 'COUNT' and 'UNTIL' are mutually exclusive at positions 11, 19 and 27:

        'FREQ=DAILY;COUNT=3;COUNT=7;UNTIL=20200302;INTERVALLLLL=9'
                    ^^^^^   ^^^^^   ^^^^^
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant