Added validation to ExpressionParser.py #48
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've read from #7 that cron validation is not the scope of this project but seeing multiple issues over the year
I have implement it myself. tested with my personal test case below and also passed test from pre-commit hook(obviously)
validation occurs just before normalize_expression in ExpressionParser.py
please review this and let me know if there are bugs to fix
`
valid_expr_ls = [
'* * * 1 ',
'0-59 * * 1 * 1',
'/59 * * 1 * 1',
'1-2/59 * * 1 * 1',
'57,59 * * 1 * 1',
'1,2,3-15 * * 1 * 1',
'1-2,2,3-15 * * 1 * 1',
'* * * 1 ',
' 0-59 * 1 * 1',
'* /59 * 1 * 1',
' 1-2/59 * 1 * 1',
'* 1,59 * 1 * 1',
'* 1,2,3-15 * 1 * 1',
'* 1-2,2,3-15 * 1 * 1',
'* * 1 ? * * ',
' * 1-12 ? * * ',
' * /12 ? * * ',
' * 1/12 ? * * ',
' * 1-5/12 ? * * ',
' * 1,23 ? * * ',
' * 1,2,7-23 ? * * ',
' * 1-2,2,7-23 ? * * ',
' * * ? * * ',
' * * 1 * * ',
' * * 31 * * ',
' * * /31 * * ',
' * * 1-2/31 * * ',
' * * 1,20 * * ',
' * * l-31 * * ',
' * * lw * * ',
' * * LW * * ',
' * * 1W * * ',
' * * 31W * * ',
' * * W21 * * 0/2',
' * * ? 1 * ',
' * * ? 12 * ',
' * * ? JAN * ',
' * * ? 1-12 * ',
' * * ? JAN-DEC * ',
' * * ? 1/12 * ',
' * * ? 1-5/12 * ',
' * * ? /12 * ',
' * * ? 1,2,3 * ',
' * * ? 1,Feb,3 * ',
' * * ? 1,5,6-12 * ',
' * * ? 1-2,5,6-12 * ',
' * * ? JAN-FEB,5,6-12 * ',
' * * ? * 0 ',
' * * ? * 6 ',
' * * ? * SUN ',
' * * ? * /6 ',
' * * ? * 0/6 ',
' * * ? * 0-1/6 ',
' * * ? * 0-1 ',
' * * ? * MON-wed ',
' * * ? * MON-wed,sun,4 ',
' * * ? * MON,3 ',
' * * ? * 2L ',
' * * ? * 6L ',
' * * ? * 0#3 ',
' * * ? * * 1970',
' * * ? * * 2099',
' * * ? * * 1970-2099',
' * * ? * * /129',
' * * ? * * 1970/129',
'* * * ? * * 1970-2001/129',
'* * * ? * * 1970,1971,2099',
'* * * ? * * 1970-1971,1972,2000-2002',
'* * * * * 2013'
]
for expr in valid_expr_ls:
print(get_description(expr, options))
`