Skip to content

Commit cd37e34

Browse files
committed
fix(cron): accept day-of-week 7 as a valid Sunday alias
Standard cron syntax allows weekday values 0–7, where both 0 and 7 mean Sunday (documented in crontab(5) and implemented by vixie-cron, cronie, fcron, and most Unix cron daemons). The validator was enforcing a max of 6, rejecting valid expressions like `* * * * 7`, `0 0 * * 0-7`, and `0 0 * * 0,7`. Change the weekday upper bound from 6 to 7 and add three test cases that were previously (incorrectly) rejected.
1 parent 70de324 commit cd37e34

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/validators/cron.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def cron(value: str, /):
7272
return False
7373
if not _validate_cron_component(months, 1, 12):
7474
return False
75-
if not _validate_cron_component(weekdays, 0, 6):
75+
if not _validate_cron_component(weekdays, 0, 7):
7676
return False
7777

7878
return True

tests/test_cron.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
"0 3-6 * * *",
2323
"*/15 0,6,12,18 * * *",
2424
"0 12 * * 0",
25+
"0 12 * * 7",
26+
"0 0 * * 0-7",
27+
"0 0 * * 0,7",
2528
"*/61 * * * *",
2629
# "5-10/2 * * * *", # this is valid, but not supported yet
2730
],

0 commit comments

Comments
 (0)