-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Context
- node version: 5.0.0
- joi version: 9.0.0
- environment (node, browser): Node
- used with (hapi, standalone, ...): Standalone
- any other relevant information:
What are you trying to achieve or the steps to reproduce ?
When setting a value to be treated as empty (such as null) and setting the required flag, the empty value is not caught by the required validator. The required check in 'Any' only checks explicitly for 'undefined' and does not check any set empty values.
The main goal is to treat null as if it was undefined.
const schema = Joi.object({
myKey: Joi.string().empty(null).required()
});
schema.validate({ myKey: null });Which result you had ?
Returns with no errors.
What did you expect ?
Expected 'myKey' to be treated as an empty value the same as 'undefined'
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugBug or defectBug or defect