This version requires joi v17 or newer.
const Joi = require('joi')
.extend(require('@joi/date'));
const schema = Joi.date().format('YYYY-MM-DD').utc();
Specifies the allowed date format:
format
- string or array of strings that follow themoment.js
format.
const schema = Joi.date().format(['YYYY/MM/DD', 'DD-MM-YYYY']);
const schema = Joi.date().format('YYYY-MM-DD HH:mm');
Dates will be parsed as UTC instead of using the machine's local timezone.
const schema = Joi.date().utc().format(['YYYY/MM/DD', 'DD-MM-YYYY']);