npm.io
2.1.0 • Published 9 years ago

joi-extension-date-within

Licence
MIT
Version
2.1.0
Deps
2
Vulns
3
Weekly
0
Stars
2

#Joi Extension Within Date

Build Status Coverage Status dependencies Status

An extension to Joi to enable checking that a date is within a number of days of another date property.

In the below example we are confirming that to is within 10 days of from

var Joi = require('joi').extend(require('joi-extension-date-within'));

var schema = Joi.object({
  from: Joi.date().required(),
  to: Joi.dateWithin().required().days(10, Joi.ref('from'))
});

var input = {
  from: new Date(2016,3,1),
  to: new Date(2016,3,30)
};

Joi.assert(input, schema)

Keywords