0

Consider the following json:

"test": {
      "required_key" : ["a", "b"],
      "a": {
          "key": "val"
      }
  }

I want using json-schema-validator to require that the values of "required_key" that is: "a", "b" will be required under the "test" tag.

That is, I want to declare required tags based on value of other tag ("required_key")

In my example the validation should fail since "b" appear on the "required_key" but is not defined inside the "test" tag

Michael A
  • 5,770
  • 16
  • 75
  • 127
  • 1
    Possible duplicate of [How do I use the \`If\` \`then\` \`else\` condition in json schema?](https://stackoverflow.com/questions/51539586/how-do-i-use-the-if-then-else-condition-in-json-schema) – Relequestual Mar 07 '19 at 08:46
  • You can only do this if you know all the possible values. You cannot dynamically reference part of the instance JSON in the Schema. – Relequestual Mar 07 '19 at 08:47

0 Answers0