Allow optional parameters in Joi without specifying them
You can set allowUnknown
to true
in options
:
validate: {
payload: {
email : Joi.string().required(),
password : Joi.string().required(),
},
options: {
allowUnknown: true
}
}
The options
parameter is passed to Joi on validation.
For current version of Joi (v15.1.0), while doing
Joi.validate(value, schema, options)
set allowUnknown: true
into the options
object.
Reference:
https://github.com/hapijs/joi/blob/v15.1.0/API.md#validatevalue-schema-options-callback