Skip to content

Latest commit

 

History

History
executable file
·
34 lines (23 loc) · 716 Bytes

API.md

File metadata and controls

executable file
·
34 lines (23 loc) · 716 Bytes

Compatibility

This version requires joi v17 or newer.

Usage

const Joi = require('joi')
    .extend(require('@joi/date'));

const schema = Joi.date().format('YYYY-MM-DD').utc();

Rules

date.format(format)

Specifies the allowed date format:

  • format - string or array of strings that follow the moment.js format.
const schema = Joi.date().format(['YYYY/MM/DD', 'DD-MM-YYYY']);
const schema = Joi.date().format('YYYY-MM-DD HH:mm');

date.utc()

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']);