{"id":13672849,"url":"https://github.com/GuillaumeRochat/cron-validator","last_synced_at":"2025-04-28T04:30:36.175Z","repository":{"id":42991042,"uuid":"184285416","full_name":"GuillaumeRochat/cron-validator","owner":"GuillaumeRochat","description":"Validates cron expressions","archived":false,"fork":false,"pushed_at":"2024-05-26T19:35:57.000Z","size":451,"stargazers_count":77,"open_issues_count":4,"forks_count":20,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-09-19T01:29:23.187Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GuillaumeRochat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-04-30T15:17:08.000Z","updated_at":"2024-09-10T07:31:46.000Z","dependencies_parsed_at":"2024-01-17T04:18:48.702Z","dependency_job_id":null,"html_url":"https://github.com/GuillaumeRochat/cron-validator","commit_stats":{"total_commits":47,"total_committers":8,"mean_commits":5.875,"dds":0.276595744680851,"last_synced_commit":"97ee1ebb8ca9da5db38b05ffa9324381096ff612"},"previous_names":["thecloudconnectors/cron-validator"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuillaumeRochat%2Fcron-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuillaumeRochat%2Fcron-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuillaumeRochat%2Fcron-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuillaumeRochat%2Fcron-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GuillaumeRochat","download_url":"https://codeload.github.com/GuillaumeRochat/cron-validator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224095108,"owners_count":17254821,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T09:01:52.004Z","updated_at":"2024-11-11T11:30:24.386Z","avatar_url":"https://github.com/GuillaumeRochat.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Cron Validator\n\nCron Validator is a util that allows you to validate a cron expression, similar to what [crontab guru](https://crontab.guru) does, but in your code base.\n\n## Alternatives\n\n- [cron-validate](https://github.com/Airfooox/cron-validate):\n  It has more features and configuration options to restrict ranges, or create presets of configs. It includes an AWS preset that should match AWS Schedule Expressions.\n\n## Installation\n\n```\nnpm install cron-validator\n```\n\n## Usage\n\nRequire syntax:\n\n```js\nconst cron = require('cron-validator');\n\nif (cron.isValidCron('* * * * *')) {\n    // Do something\n}\n```\nOr import syntax with TypeScript:\n```ts\nimport { isValidCron } from 'cron-validator'\n\nif (isValidCron('* * * * *')) {\n    // Do something\n}\n```\n\nSupport for seconds can be enabled by passing the `seconds` flag as true in options:\n\n```js\nconst cron = require('cron-validator');\n\ncron.isValidCron('* * * * * *');\n// false\n\ncron.isValidCron('* * * * * *', { seconds: true });\n// true\n```\n\nThe same goes to enable the `alias` support for months and weekdays:\n\n```js\nconst cron = require('cron-validator');\n\ncron.isValidCron('* * * * mon');\n// false\n\ncron.isValidCron('* * * * mon', { alias: true });\n// true\n```\n\nLikewise, the `allowBlankDay` flag can be enabled to mark days or weekdays blank with a `?` symbol:\n\n```js\nconst cron = require('cron-validator');\n\ncron.isValidCron('* * * * ?');\n// false\n\ncron.isValidCron('* * * * ?', { allowBlankDay: true });\n// true\n```\n\nThe `allowSevenAsSunday` flag can be enabled to enable support for digit 7 as Sunday:\n\n```js\nconst cron = require('cron-validator');\n\ncron.isValidCron('* * * * 7');\n// false\n\ncron.isValidCron('* * * * 7', { allowSevenAsSunday: true });\n// true\n```\n\nThe `allowNthWeekdayOfMonth` flag can be enabled to enable expressions denoting n-th weekday of the month:\n\n```js\nconst cron = require('cron-validator');\n\ncron.isValidCron('* * * * tue#2');\n// false\n\ncron.isValidCron('* * * * tue#2', { allowNthWeekdayOfMonth: true }); // second Tuesday of each month\n// true\n```\n\n## Features\n\n- [x] Support seconds.\n- [x] Support alias.\n- [x] Support blank day notation with `?` symbol.\n- [x] Support both 0-6 and 1-7 ranges for weekdays.\n- [x] Support n-th weekday of month such as `TUE#2`\n- [ ] ~~Have an explain mode returning the fragments in error.~~\n\n## Motivations\n\n**Many great cron libraries already exists on NPM, why this one?**\n\nLibraries like [node-cron](https://github.com/kelektiv/node-cron) are primarily made to schedule jobs using a cron expression, not validate those cron expressions. They come with additional behaviors not always required. They also bring their own set of defaults which might be in conflicts with the defaults of other external systems. We needed something to validate an expression before sending it off to an external system, so we created this to be a little more strict and configurable, with a more specific behavior.\n\nWe decided to go for the naive approach first, which results in lenghty code and tests, but also making it easier to reason about cron expressions and their specific rules.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGuillaumeRochat%2Fcron-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGuillaumeRochat%2Fcron-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGuillaumeRochat%2Fcron-validator/lists"}