-
Notifications
You must be signed in to change notification settings - Fork 628
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
feat: add isCronTimeValid function to validate cron expressions #959
Conversation
873341d
to
155a77c
Compare
Works for me, thanks for the PR! @intcreator what's your take on adding this feature? |
Since the parsing function returns the reason why a cron time would be invalid, it could be interesting to find a way to return the error. |
Good point! I see two possible approaches here:
{
valid: boolean;
error?: Error;
}
const error = isCronExpressionInvalid('not valid');
if (error) {
// Handle the error
} Which one do you think fits best with the project's style? |
I think the first approach with a function named P.S. probably wait for @intcreator's feedback just in case! |
I agree with that approach @sheerlox |
4dff34d
to
158fcaa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the test comment, LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution ❤️
oops, merged with the wrong function name in the commit message 😆 |
🎉 This PR is included in version 4.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
This PR adds a function isCronTimeValid to validate CRON expressions without using try/catch blocks.
Related Issue
Issue #958
Motivation and Context
Makes it easier to validate CRON expressions
How Has This Been Tested?
Added two new test cases
Screenshots (if appropriate):
Types of changes
Checklist:
!
after the type/scope in the title (see the Conventional Commits standard).