JSON schema - valid if object does *not* contain a particular property
json, jsonschema
Solution
What you want to do can be achieved using the `not` keyword. If the `not` schema validates, the parent schema will not validate.
{
"type": "object",
"properties": {
"x": { "type": "integer" }
},
"required": [ "x" ],
"not": { "required": [ "z" ] }
}
Problem
Is it possible to set up a JSON schema that still allows for `additionalProperties` but does not match if a very particular property name is present? In other words, I need to know if it's possible to have the exact opposite of the `required` declaration. Schema: ``` { "type": "object", "properties": { "x": { "type": "integer" } }, "required": [ "x" ], "ban": [ "z" ] // possible? } ``` Match: ``` { "x": 123 } ``` Match: ``` { "x": 123, "y": 456 } ``` Do not match: ``` { "x": 123, "y": 456, "z": 789 } ```