diff --git a/src/validation.jl b/src/validation.jl index f121be0..680f9ef 100644 --- a/src/validation.jl +++ b/src/validation.jl @@ -169,26 +169,25 @@ end function _validate(x, schema, ::Val{:if}, val, path::String) # ignore if without then or else if haskey(schema, "then") || haskey(schema, "else") - ret = _if_then_else(x, schema, path) - return ret + return _if_then_else(x, schema, path) end return end + # 9.2.2.2: then function _validate(x, schema, ::Val{:then}, val, path::String) # ignore then without if if haskey(schema, "if") - ret = _if_then_else(x, schema, path) - return ret + return _if_then_else(x, schema, path) end return end + # 9.2.2.3: else function _validate(x, schema, ::Val{:else}, val, path::String) # ignore else without if if haskey(schema, "if") - ret = _if_then_else(x, schema, path) - return ret + return _if_then_else(x, schema, path) end return end @@ -196,7 +195,9 @@ end """ _if_then_else(x, schema, path) -The if, then and else keywords allow the application of a subschema based on the outcome of another schema. Details are in the link and the truth table is as follows: +The if, then and else keywords allow the application of a subschema based on the +outcome of another schema. Details are in the link and the truth table is as +follows: ``` ┌─────┬──────┬──────┬────────┐ @@ -208,8 +209,10 @@ The if, then and else keywords allow the application of a subschema based on the │ F │ n/a │ F │ F │ │ n/a │ n/a │ n/a │ T │ └─────┴──────┴──────┴────────┘ -https://json-schema.org/understanding-json-schema/reference/conditionals#ifthenelse ``` + +See https://json-schema.org/understanding-json-schema/reference/conditionals#ifthenelse +for details. """ function _if_then_else(x, schema, path) if _validate(x, schema["if"], path) !== nothing