Closed davidcl64 closed 9 years ago
I am not sure that this behavior of Joi should bleed through to generic behavior of validation for swagger.
We do it to coerce primitives on path parameters, but that's as a convenience for type. It doesn't remove properties.
Fair enough - I had an internal debate with myself about this as well :).
In my case, using the Joi internals was the only way I could begin using this library and maintain backwards compatibility with an existing API.
In this case, though, replacing the body with the validated version using the default settings (ie: without me diving into the internals of joi) would end up with a body that was identical to the original wouldn't it?
:+1:
This already landed - not sure why the PR wasn't automatically closed.
In some cases, passing additional options to the validator causes the incoming data to be changed.
For example, adding the enjoi settings:
Will cause any incoming, unknown properties to be removed from the object that is being validated.
This change ensures those results are used rather than the original, pre-validated object.