@meanie/joi-moment

2.5.1 • Public • Published

@meanie/joi-moment

npm version node dependencies github issues

A Joi extension to automatically convert ISO date strings to moment objects

Meanie

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 or endOf
  • Able to validate using moment functions like isAfter or isBefore

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

Package Sidebar

Install

npm i @meanie/joi-moment

Weekly Downloads

117

Version

2.5.1

License

MIT

Unpacked Size

10.2 kB

Total Files

3

Last publish

Collaborators

  • adamreisnz