feat(isCron): add cron expression validator - #2837
Open
Dueen wants to merge 3 commits into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2837 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 114 115 +1
Lines 2598 2662 +64
Branches 658 676 +18
=========================================
+ Hits 2598 2662 +64 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new public validator, isCron, to validator.js for validating common five-field Unix cron expressions (with optional opt-in support for a leading seconds field), and documents/validates the supported dialect.
Changes:
- Added
src/lib/isCron.jsimplementing cron parsing/validation (lists, ranges, positive steps, month/weekday names, and standard@...aliases). - Exported the new validator via
src/index.jsso it becomes part of the public API. - Added focused unit tests and README documentation for the new validator.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/validators/isCron.test.js | Adds valid/invalid coverage for 5-field cron, aliases, optional seconds field, and a performance-regression guard. |
| src/lib/isCron.js | Implements isCron validation logic for Unix-style cron expressions and standard aliases. |
| src/index.js | Wires isCron into the public validator export surface. |
| README.md | Documents isCron behavior, supported syntax, and the allow_seconds option. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rubiin
approved these changes
Aug 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
isCronvalidator for common five-field Unix cron expressions{ allow_seconds: true }Motivation
Closes #2301.
This follows the discussion in #2301 and the earlier attempt in #2306. The validator defaults to the common five-field Unix format and keeps the six-field leading-seconds form opt-in so it does not silently mix Unix and Quartz cron dialects. Quartz-only tokens such as
?,L,W, and#are intentionally rejected.Validation
npm test(build, lint, and 325 passing tests)References
Checklist