Date validation methods.
See the list of accepted formats at moment's documentation.
component install nib-health-funds/date-validators
Returns a method that will return whether a value is a string, adheres to the specified format and parts are in a valid range for a date (e.g. 13 is an invalid month).
Returns a method that will return whether a value is valid and less than the specified date.
Returns a method that will return whether a value is valid and less than or equal to the specified date.
Returns a method that will return whether a value is valid and greater than the specified date.
Returns a method that will return whether a value is valid and greater than or equal to the specified date.
var
now = new Date(),
validators = require('date-validators')
;
validators.valid('YYYY-MM-DD')('asdfsadf'); //false
validators.valid('YYYY-MM-DD')('01/01/2015'); //false
validators.valid('YYYY-MM-DD')('2015-01-01'); //true
validators.lessThan(now, 'YYYY-MM-DD')('2015-01-01'); //false (at least for *now*)
validators.lessThan(now, 'YYYY-MM-DD')('2012-01-01'); //true
validators.greaterThan(now, 'YYYY-MM-DD')('2012-01-01'); //false
validators.greaterThan(now, 'YYYY-MM-DD')('2015-01-01'); //true (at least for *now*)