From cd37e34881873d9e4c1952931e9538b8d5092ce7 Mon Sep 17 00:00:00 2001 From: Vincent Gao Date: Wed, 24 Jun 2026 21:58:11 +0200 Subject: [PATCH] fix(cron): accept day-of-week 7 as a valid Sunday alias MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/validators/cron.py | 2 +- tests/test_cron.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/validators/cron.py b/src/validators/cron.py index a8449b6a..f5daba05 100644 --- a/src/validators/cron.py +++ b/src/validators/cron.py @@ -72,7 +72,7 @@ def cron(value: str, /): return False if not _validate_cron_component(months, 1, 12): return False - if not _validate_cron_component(weekdays, 0, 6): + if not _validate_cron_component(weekdays, 0, 7): return False return True diff --git a/tests/test_cron.py b/tests/test_cron.py index e0b2a199..52482fbb 100644 --- a/tests/test_cron.py +++ b/tests/test_cron.py @@ -22,6 +22,9 @@ "0 3-6 * * *", "*/15 0,6,12,18 * * *", "0 12 * * 0", + "0 12 * * 7", + "0 0 * * 0-7", + "0 0 * * 0,7", "*/61 * * * *", # "5-10/2 * * * *", # this is valid, but not supported yet ],