Title: fix(cron): validate comma-separated lists of ranges and steps by patchwright · Pull Request #463 · python-validators/validators · GitHub
Open Graph Title: fix(cron): validate comma-separated lists of ranges and steps by patchwright · Pull Request #463 · python-validators/validators
X Title: fix(cron): validate comma-separated lists of ranges and steps by patchwright · Pull Request #463 · python-validators/validators
Description: Summary cron() rejects valid expressions whose components are comma-separated lists of ranges or steps, e.g. cron("1-5,10-20 * * * *") raises ValidationError even though the expression is valid. Reproduction from validators import cron cron("1-5,10-20 * * * *") # ValidationError (incorrect) cron("1-5,30 * * * *") # ValidationError (incorrect) Validity currently depends on element order, which is the clearest sign this is a bug rather than an intended limitation: cron("30,1-5 * * * *") # True cron("1-5,30 * * * *") # ValidationError (same tokens, different order) Cause In src/validators/cron.py, _validate_cron_component checks the "-" and "/" branches before the "," branch. A component like "1-5,10-20" therefore matches the range branch, split("-") yields three parts, and the whole expression is rejected. Fix Evaluate the "," branch first, recursing on each element so each element can itself be a single value, a range ("1-5"), or a step ("*/2"). if component == "*": return True + if "," in component: + for item in component.split(","): + if not _validate_cron_component(item, min_val, max_val): + return False + return True + if component.isdecimal(): No previously-accepted input changes behaviour: any component containing a comma previously hit the range branch and was rejected, so this only accepts inputs that were wrongly rejected. The existing dead commented all(...) block is removed. Tests Adds four cases to test_returns_true_on_valid_cron: "1-5,10-20 * * * *" "1-5,30 * * * *" "10,20-30 * * * *" "1-5,10-20,30-40 * * * *" Each fails on the current code and passes with the fix. Full suite: 895 → 899 passing. ruff check / ruff format clean. I couldn't find an existing issue or PR covering this — happy to fold it into one if I missed it.
Open Graph Description: Summary cron() rejects valid expressions whose components are comma-separated lists of ranges or steps, e.g. cron("1-5,10-20 * * * *") raises ValidationError even though the expression is...
X Description: Summary cron() rejects valid expressions whose components are comma-separated lists of ranges or steps, e.g. cron("1-5,10-20 * * * *") raises ValidationError even though the expre...
Opengraph URL: https://github.com/python-validators/validators/pull/463
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:2bb8f7df-5abb-e1cf-5418-b37114847c63 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 845A:39E76C:81FC7A:B2DBDF:6A538DF0 |
| html-safe-nonce | 97bdec88f94ac8442c18faf7912f1e752d5528aa6078c9cb1978f532c27ff5ab |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NDVBOjM5RTc2Qzo4MUZDN0E6QjJEQkRGOjZBNTM4REYwIiwidmlzaXRvcl9pZCI6IjIxODQzMTc2OTE5MTYxNTk4NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8f1f553e3dc72857f876048439e0d7b5e8761db76b605ce46902968e4c2f3acc |
| hovercard-subject-tag | pull_request:3863049327 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python-validators/validators/pull/463/files |
| twitter:image | https://avatars.githubusercontent.com/u/292882882?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/292882882?s=400&v=4 |
| og:image:alt | Summary cron() rejects valid expressions whose components are comma-separated lists of ranges or steps, e.g. cron("1-5,10-20 * * * *") raises ValidationError even though the expression is... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/python-validators/validators git https://github.com/python-validators/validators.git |
| octolytics-dimension-user_id | 113113270 |
| octolytics-dimension-user_login | python-validators |
| octolytics-dimension-repository_id | 13642984 |
| octolytics-dimension-repository_nwo | python-validators/validators |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 13642984 |
| octolytics-dimension-repository_network_root_nwo | python-validators/validators |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width