1
{
  "title":"x",
  "type:"string",
  "doesNotMatch":["element1","element2"]
}

Is there JSON schema which ensures that the JSON data will not match element1 and element2.

  • {"x":element1} is invalid
  • {"x":"daf"} valid provided "daf" is not equal to element1 and element2
Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111
Punit Kulal
  • 79
  • 1
  • 8

1 Answers1

3

not enum should help you:

{
  "title":"x",
  "type:"string",
  "not": {"enum":["element1","element2"]}
}
vearutop
  • 3,924
  • 24
  • 41
  • Just for Punit Kulal reference: please see: http://json-schema.org/latest/json-schema-validation.html#logic as well as e.g. https://stackoverflow.com/a/48045287/2811843 for some clarifications on translating boolean logic into JSON Schema – PsychoFish Nov 19 '18 at 09:25