Closed bnadim closed 7 years ago
Fields with format option become required even if they are written as optional
const BaseJoi = require('joi') const Extension = require('joi-date-extensions') const Joi = BaseJoi.extend(Extension) const schema = Joi.object().required().keys({ date: Joi.date().format('YYYY-MM-DD').optional() }); const data = { } Joi.validate(data, schema, { allowUnknown: true }, (err, validatedData) => { if (err) { console.log('Validation error : ', err) } else { console.log('Validation success') } })
'"date" must be a string with one of the following formats YYYY-MM-DD'
Data should be a valid result
Thanks for the report, patch published.
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.
Context
What are you trying to achieve or the steps to reproduce ?
Fields with format option become required even if they are written as optional
Which result you had ?
'"date" must be a string with one of the following formats YYYY-MM-DD'
What did you expect ?
Data should be a valid result