joi icon indicating copy to clipboard operation
joi copied to clipboard

Validate without applying default values

Open ludoblues opened this issue 11 years ago • 6 comments

I need to be able to tune if a want the joi default values to be applied or not when validating my data.

I was thinking about an option "ignoreDefaults": joi.validate(data, schema, { ignoreDefaults: true }). I would like to know what do you think about it before pushing a PR.

Thanks.

ludoblues avatar Jul 10 '15 12:07 ludoblues

What's the use case ?

Marsup avatar Jul 10 '15 12:07 Marsup

My default values varies between different contexts. So when i am outside of this context, and i just want to validate my datas, there is no sense to apply default values.

ludoblues avatar Jul 10 '15 13:07 ludoblues

Do you still need coercion ?

Marsup avatar Jul 10 '15 13:07 Marsup

Yes, i would like to be able to use it with other options like stripUnknown.

ludoblues avatar Jul 10 '15 13:07 ludoblues

OK why not, let's go for a noDefaults.

Marsup avatar Jul 10 '15 16:07 Marsup

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.

lock[bot] avatar Jan 09 '20 05:01 lock[bot]