# cron-expression-validator

> Validate cron expressions

Latest version **1.0.20** (published 2021-06-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install cron-expression-validator
pnpm add cron-expression-validator
yarn add cron-expression-validator
bun add cron-expression-validator
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.20 |
| Published | 2021-06-06 |
| First published | 2020-05-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 25 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Anusha Ihalapathirana |
| Maintainers | ihalapathirana |
| Keywords | cron, cron-validation, validation, cron-expression-validator, cron validation error message, error message, node cron, node-cron, quartz, cron-expression, node.js |

## Links

- npm: https://www.npmjs.com/package/cron-expression-validator
- Repository: https://github.com/anushaihalapathirana/cron-expression-validator
- Homepage: https://github.com/anushaihalapathirana/cron-expression-validator#readme
- Issues: https://github.com/anushaihalapathirana/cron-expression-validator/issues
- npm.io page: https://npm.io/package/cron-expression-validator

## Alternatives

- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads

## Recent versions

- 1.0.20 (latest) — 2021-06-06
- 1.0.19 — 2021-06-05
- 1.0.18 — 2020-06-18
- 1.0.17 — 2020-05-20
- 1.0.16 — 2020-05-07
- 1.0.15 — 2020-05-07
- 1.0.14 — 2020-05-07
- 1.0.13 — 2020-05-03
- 1.0.11 — 2020-05-03
- 1.0.10 — 2020-05-03
- 1.0.9 — 2020-05-03
- 1.0.8 — 2020-05-03
- 1.0.7 — 2020-05-03
- 1.0.6 — 2020-05-03
- 1.0.5 — 2020-05-03
- … 5 more at https://npm.io/package/cron-expression-validator/versions

## README

[![typescript](https://camo.githubusercontent.com/56e4a1d9c38168bd7b1520246d6ee084ab9abbbb/68747470733a2f2f62616467656e2e6e65742f62616467652f69636f6e2f547970655363726970743f69636f6e3d74797065736372697074266c6162656c266c6162656c436f6c6f723d626c756526636f6c6f723d353535353535)](https://www.typescriptlang.org/)

# cron-expression-validator

cron-expression-validator is a **Node.JS** library (support typescript) to validate **quartz** cron expressions 

## Installation

	npm install cron-expression-validator
  
## Usage

**isValidCronExpression** method reqire *string* (cron expression) as parameter and returns *boolean* value

``` js
var cronValidator = require('cron-expression-validator');
var isValid = cronValidator.isValidCronExpression("* * * * * ? *"); // returns true
```
```js
if(cronValidator.isValidCronExpression("* * * * * ? *")) { // returns true
	// Your code
}
```
```js
if(cronValidator.isValidCronExpression("* * * * * * *")) { 
	// returns false
}
```


### Optional second param if you want to get error message

Can get error message by passing ``` { error: true } ``` as second parameter


```js
if(cronValidator.isValidCronExpression("* * * * 25/2 ? *", {error: true}) {
/** returns {
/* 		isValid: false,
/* 		errorMessage: [ 'Month values must be between 1 and 12' ]
/*	}
**/
}
```

``` js
if(cronValidator.isValidCronExpression("* * * ? * * 123/555", {error: true}) {
/** returns {
/* 		isValid: false,
/* 		errorMessage: [ '(Year) - Unsupported value 123 for field. Possible values are 1970-2099 , - * /',
/*				'(Year) - Expression 555 is not a valid increment value. Accepted values are 0-129' 
/*				]
/*	}
**/
}
```
  
``` js
if(cronValidator.isValidCronExpression("0 0 12 1/2 * ? *", {error: false}) { // returns true
	// Your code
}
```
## Cron accepted values
	Seconds: 0-59 * , -
	Minutes: 0-59 * , -
	Hours: 0-23 * , -
	Day of Month: 1-31 * , - ? L LW
	Months: (JAN-DEC or 1-12) * , -	
	Day of Week: (SUN-SAT or 1-7) * , L - ? #
	Year: 1970-2099 * , -
  
## License
	MIT

---
_Source: https://npm.io/package/cron-expression-validator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
