cron-quartz-validator
v2.1.1
Published
cron quartz expression validator
Downloads
462
Maintainers
Readme
cron-quartz-validator
cron-quartz-validator is a Node.js library (written in TypeScript) to validate Quartz cron expressions.
Installation
npm install cron-quartz-validatorUsage
validateCronExpression takes a string (the cron expression) and returns { valid: boolean, errors: string[] }:
import { validateCronExpression } from "cron-quartz-validator";
validateCronExpression("0 0 12 * * ?");
// { valid: true, errors: [] }
validateCronExpression("* * * * * * *");
// { valid: false, errors: [ ... ] }
validateCronExpression("* * * * 25/2 ? *");
// { valid: false, errors: [ "Month must be between 1 and 12, or JAN-DEC" ] }isValidCronExpression is a convenience wrapper that just returns the boolean:
import { isValidCronExpression } from "cron-quartz-validator";
if (isValidCronExpression("0 0 12 1/2 * ? *")) {
// Your code
}Cron accepted values
Seconds: 0-59 * , - /
Minutes: 0-59 * , - /
Hours: 0-23 * , - /
Day of Month: 1-31 * , - / ? L LW
Month: 1-12 or JAN-DEC * , - /
Day of Week: 1-7 or SUN-SAT * , - / ? L #
Year: 1970-2199 * , - / (optional 7th field)Development
pnpm i
pnpm typecheck # tsc --noEmit
pnpm lint # eslint .
pnpm test # vitest run
pnpm build # tsc -p tsconfig.build.json -> dist/CI runs typecheck, lint, and the test suite on every push to main and on every pull request (.github/workflows/test.yml). Every push to main also bumps package.json's patch version and commits it back (.github/workflows/bump-version.yml). Publishing to npm happens via .github/workflows/publish.yml, triggered by pushing a v*.*.* tag — the published version is taken from the tag itself (not from package.json), so tagging is what actually decides a release's version. Dependabot keeps dependencies and workflow actions up to date (.github/dependabot.yml).
License
ISC
