npm

Share private packages across your team with npm Orgs, now with simplified billing via the aws marketplace!Learn more »

sancronos-validator

1.2.0 • Public • Published

sancronos-validator

NPM Version NPM Downloads Build Status bitHound Overall Score bitHound Dependencies bitHound Dev Dependencies bitHound Code Codacy Badge Code Climate Issue Count

About

Cron expression validator

NPM

Settings

Install sancronos-validator

$ npm install sancronos-validator

Use

Accepts clasic crontab

  x    x    x    x    x
  ┬    ┬    ┬    ┬    ┬
  │    │    │    │    │
  │    │    │    │    │
  │    │    │    │    └───── day of week (0 - 7, - * /) (0 or 7 is sunday)
  │    │    │    └────────── month (1 - 12 , - * /)
  │    │    └─────────────── day of month (1 - 31 , - * /)
  │    └──────────────────── hour (0 - 23 , - * /)
  └───────────────────────── minutes (0 - 59 , - * /)

Accepts extended crontab

  x    x    x    x    x    x    x
  ┬    ┬    ┬    ┬    ┬    ┬    ┬
  │    │    │    │    │    │    │
  │    │    │    │    │    │    └ year (1900 - 3000 , - * /) optional
  │    │    │    │    │    └───── day of week (0 - 7 , - * / L #) (0 or 7 is sunday)
  │    │    │    │    └────────── month (1 - 12 , - * /)
  │    │    │    └─────────────── day of month (1 - 31 , - * / L W)
  │    │    └──────────────────── hour (0 - 23 , - * /)
  │    └───────────────────────── minutes (0 - 59 , - * /)
  └────────────────────────────── seconds (0 - 59 , - * /) optional

But... who can use sancronos-validator?

Answer: Everyone!

For Promise lovers

const sancronos = require("sancronos-validator");
//..
sancronos.isValid("* * * * *")
.then(function(crontab) {
  //.. do something
})
.catch(function(err) {
  // handle error
});

For callback lovers

const sancronos = require("sancronos-validator");
//..
sancronos.isValid("* * * * *", (err, crontab) => {
  if(err){
    //Oops I did it again!
  }
  //Do something with your newly validated crontab
});

For sync lovers

const sancronos = require("sancronos-validator");
//..
let crontab = sancronos.isValid("* * * * *", true);
//Do something with your crontab
//Be aware that in case it's invalid, it will throw an error.

See test/ for more details.

Changelog

1.2.0 (18-07-2017)

  • Added callbacks
  • Added sync

1.0.1 (11-07-2017)

  • README with examples.

1.0.0 (11-07-2017)

Start

install

npm i sancronos-validator

Downloadsweekly downloads

244

version

1.2.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
Report a vulnerability