module JSI
module Schema::Validation::IfThenElse
def internal_validate_ifthenelse(result_builder)
if keyword?('if')
if_result = result_builder.inplace_subschema_validate(['if'])
result_builder.merge_schema_issues(if_result)
if if_result.valid?
if keyword?('then')
then_result = result_builder.inplace_subschema_validate(['then'])
result_builder.validate(
then_result.valid?,
'instance did not validate against the schema defined by `then` value after validating against the schema defined by the `if` value',
keyword: 'if',
results: [then_result],
)
end
else
if keyword?('else')
else_result = result_builder.inplace_subschema_validate(['else'])
result_builder.validate(
else_result.valid?,
'instance did not validate against the schema defined by `else` value after not validating against the schema defined by the `if` value',
keyword: 'if',
results: [else_result],
)
end
end
else
if keyword?('then')
result_builder.schema_warning('`then` has no effect without adjacent `if` keyword', 'then')
end
if keyword?('else')
result_builder.schema_warning('`else` has no effect without adjacent `if` keyword', 'else')
end
end
end
end
end