AndrewKeig/express-validation

Joi.default() should NOT alter the passed req.body

abdelrahman-elkady opened this issue · 1 comments

Hello there,

After some debugging, I was in doubt that adding .default() to the schema would actually extend the req.body with this default, I did a test, and yes, it did so, apparently, this was added in #16

Honestly, I see this package as a thin validation layer, it should only do what Joi does, just validate the passed object with a schema, and not to mutate any passed object

default in Joi would not mutate the passed object, it is just used to have some default value in the schema itself, useful in refs for example

I would argue that the mutation of the request should be avoided, or at least, have some option to mutate/validate the request only

What do you think ?