Closed
Description
This can be seen as the extension of #31 and #64. I see it as the syntax sugar for existing boolean/compound keywords.
The validation process is very simple:
- if the schema in
if
is valid, than the schema inthen
should be validated and its outcome determines the instance validation. - if the schema in
if
is invalid then the schema inelse
should be validated and its outcome determines the instance validation. - if
if
is not present then the schema itself is invalid (metaschema validation will fail). - if neither
then
norelse
is present - the same as above
As I've written in some issue the schema with if/then/else:
{
"if": {"$ref": "condition" },
"then": {"$ref": "schema1"},
"else": {"$ref": "schema2"}
}
is a boolean operation and it is equivalent to the schema below that is possible now:
{
"anyOf": [
{ "allOf": [ {"$ref": "condition" }, {"$ref": "schema1"} ] },
{ "allOf": [ {"not": {"$ref": "condition" } }, {"$ref": "schema2"} ] }
]
}
so if/then/else is as declarative as existing keywords but it provides a more convenient, clear and performance efficient alternative ("condition" will never be validated twice) for a quite common validation scenario.