@meanie/joi-moment
v2.5.1
Published
A Joi extension to automatically convert ISO date strings to moment objects and validate using moment functions
Downloads
1,928
Readme
@meanie/joi-moment
A Joi extension to automatically convert ISO date strings to moment objects
Features
- Validates incoming date values as ISO date strings
- Automatically converts date strings to
moment
objects - Able to specify timezone and use modifiers like
startOf
orendOf
- Able to validate using moment functions like
isAfter
orisBefore
Installation
#npm
npm install @meanie/joi-moment
#yarn
yarn add @meanie/joi-moment
Usage
const Joi = require('@hapi/joi');
const JoiMoment = require('@meanie/joi-moment');
module.exports = Joi.extend(JoiMoment);
Examples
const schema = Joi.object({
startDate: Joi.moment().tz(timezone).startOf('day'),
endDate: Joi.moment().tz(timezone).endOf('day').isAfter(Joi.ref('startDate')),
});
Issues & feature requests
Please report any bugs, issues, suggestions and feature requests in the meanie-joi-moment issue tracker.
Contributing
Pull requests are welcome! If you would like to contribute to Meanie, please check out the Meanie contributing guidelines.
Sponsor
This package has been kindly sponsored by Hello Club, an all in one club and membership management solution complete with booking system, automated membership renewals, online payments and integrated access and light control. Check us out if you happen to belong to any kind of club or if you know someone who helps run a club!
License
(MIT License)
Copyright 2019-2020, Adam Reis