I am creating a JSON schema and I have a boolean variable in the schema. When this boolean is true
, I want some properties of the schema to be required. When this boolean is false
, I want other properties of the schema to be required.
Ex (pretend like JSON has comments with //):
{
"my_boolean": false, // boolean which determines which schema to use
"field1": "someString" // required when my_boolean is false, optional when true
"field2": "someOtherString" // required when my_boolean is true, optional when false
}
I assume I want some sort of anyOf
specification, but I can't think of how to define "when true do this when false do that". I came across this SO post and implication is exactly what I want, but the library I'm using for validation only supports up to JSON schema draft 04.