Open naz opened 3 years ago
To move on with the implementation I've ended up using cron-parser to validate cron expressions before calling later.parse.cron
. Might serve as a good reference for parsing logic
Had a look into what bree does with this exact problem and saw that it's running cron expression validation against cron-validate.
If the validation for cron expressions is moved into later
's layer, I think it will make the logic for both cron and text expressions-to-schedule transformations more consistent.
Just noticed the same issue. Would make sense to use same as for text
parser as right now cron
gives me 0 for error
all the time and that complicates everything.
I also noticed now that later
is not validating cron strings, is there a plan to add this or do I need to validate it manually?
refs https://github.com/bunkat/later/issues/174
Problem
As pointed out in referenced issue there is no error detection logic in later.parse.cron function. This introduced an inconsistency with how later.parse.text behave when invalid values are passed in. In case of
cron
method there is no indication of any type of error if completely invalid string is passed in. Contrary fortext
method there'serror
property assigned to returned object when the expression is not parsed.Possible solution
There are multiple ways I can see this issue can be approached:
text
functionPersonally I'm in favor of second approach as that would allow to unify error handling.