The Documentaion of JOI says that,
response.options Options to pass to joi during validation. Useful to set global options such as stripUnknown or abortEarly. If a custom validation function is defined via schema or status then options can an arbitrary object that will be passed to this function as the second argument.
It is not clear that what it does.
const joi = require('joi');
joi.validate(object, schema, {stripUnknown:true}, callback);
Can someone tell me what does stripUnknown does?
validate: {
payload: Joi.object({
start: Joi.string().min(1).max(4),
end: Joi.date().required()
}).options({ stripUnknown: true, abortEarly: false })
}
In the above example, stripUnknown is set to true that it will not complain if your payload has any other keys other than start and end. By default stripUnknown is false.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With