I hope that joi provide a new option of unknown to allow unknown attributes but remove it in the result.
const schema = Joi.object({
a: joi.string()
}).unknown()
schema.validate({a:'1', b: '1'}, (err, result) => {
// result = {a: '1', b: '1'}
})
the function validate will leave the unknown attributes in the object.
A new option of unknown to allow unknown key but remove it in the result
You can already do that with .options({ stripUnknown: true }). Be aware it propagates to children schemas in case you have objects or arrays inside.
@Marsup,
It works for me with this option, for instance I don't need the isolation in different hierarchy. Thank you very much. I will close this issue.
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.
Most helpful comment
You can already do that with
.options({ stripUnknown: true }). Be aware it propagates to children schemas in case you have objects or arrays inside.