serby / validity-date-before-property

Validity style validator to ensure a property has a date before another date property.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

validity-date-before-property

build status Greenkeeper badge

Validity style validator to ensure a property has a date before another date property.

Installation

  npm install validity-date-before-property

Usage

Below is a simple example for usage with schemata:

var validity = require('validity')
  , schemata = require('schemata')
  , dateBeforeProperty = require('validity-date-before-property')

var schema = schemata(
    { startDate:
      { type: Date
      , validators:
        { all: [dateBeforeProperty()]
        }
      }
      , expiryDate:
      { type: Date
      }
    })

schema.validate({ startDate: 2, expiryDate: 1 }, function (error, valid) {
  // Show the error
  console.log(valid)
})

Credits

Paul Serby follow me on twitter @serby

Licence

Licensed under the New BSD License

About

Validity style validator to ensure a property has a date before another date property.


Languages

Language:JavaScript 94.2%Language:Makefile 5.8%