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

Added validation to ExpressionParser.py #48

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Borgrabbit
Copy link
Contributor

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))

`

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

Successfully merging this pull request may close these issues.

1 participant