Adds a custom validation function to execute arbitrary code
Set a null
value for any data type regardless of whats given. I used this in a nested if/when statement to only trigger under certain conditions based on other key values.
Here's the gist:
const forceNullValue = (value, helpers) => {
// we could do all sorts of cool stuff in here, like inspect `value`, returning
// whatever custom values we want. See example in Joi documentation.
return null
};
const schema = Joi.any().custom(forceNullValue, "ignore input and force null value validation");