Skip to content

Joi.any().when is not evaluated if empty #332

@asafdav

Description

@asafdav

Joi.any().when is not evaluated it its value is empty even if the when condition is fulfilled.

For example:

 Joi.object({
   a: Joi.string().when('b', {is: true, then: Joi.required()}),
   b: Joi.boolean().default(false)
})

If you use this object to validate {b: true} the returned value will remain {b: true} but it actually should return an error.

Metadata

Metadata

Assignees

Labels

bugBug or defect

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions