joi-extension-date-within

2.1.0 • Public • Published

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)

/joi-extension-date-within/

    Package Sidebar

    Install

    npm i joi-extension-date-within

    Weekly Downloads

    16

    Version

    2.1.0

    License

    MIT

    Last publish

    Collaborators

    • jamiemcconnell