Skip to content

Required based on value on other key #166

@simme

Description

@simme

I have the following JSON objects:

{
  "batch": false,
  "name": "foobar"
}
{
  "batch": true,
  "names": ["foo", "bar", "baz"]
}

With the current implementation of Joi is it possible to make names required only if batch is true and not allowed if batch is false? Reading the docs I think no? But I'm asking because I might be missing something! :)

If not is it something that might be added to Joi or should I do that check "post validation"?

Metadata

Metadata

Assignees

Labels

featureNew functionality or improvement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions