Skip to content

Nested whens don't work #632

@mgartner

Description

@mgartner

Why doesn't this work in my schema:

var schema = Joi.object().keys({
  setting: Joi.alternatives().when('$auth.credentials.cond1', {
    is: true,
    then: Joi.number().integer().required().when('$auth.credentials.cond2', {
      is: true,
      then: Joi.invalid(100, 101)
    }),
    otherwise: Joi.forbidden()
  })
});

When $auth.credentials.cond1 is true, and setting is not provided in the input object, there is no validation error when there should be because it is required.

Metadata

Metadata

Assignees

Labels

bugBug or defectfeatureNew functionality or improvement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions