express-validation
express-validation copied to clipboard
Pass joi's options when validating schema
Alternatively to https://github.com/AndrewKeig/express-validation/pull/127
The issue is that when you overload the req object with an extra property you will get ValidationError.
E.g.,
Joi.assert(
Joi.object({body: {}, foo: {}}),
Joi.object(parameters.reduce((result, item) => ({ ...result, [item]: Joi.object() }), {})).required().min(1)
)
Will fail.
While:
Joi.assert(
Joi.object({body: {}, foo: {}}),
Joi.object(parameters.reduce((result, item) => ({ ...result, [item]: Joi.object() }), {})).required().min(1),
{allowUnknown: true}
)
Will success
This is really needed! Thanks @YonatanKiron
@AndrewKeig Any update?
~Is this addressing the same need as https://github.com/AndrewKeig/express-validation/pull/127?~ Edit: Sorry, you did specify that :sweat_smile:
Please include a test.
I have to admit that I'm not really a fan of dual-purposing the joi parameter.