module JSI
module Schema::Validation::AllOf
def internal_validate_allOf(result_builder)
if keyword?('allOf')
value = schema_content['allOf']
if value.respond_to?(:to_ary)
allOf_results = value.each_index.map do |i|
result_builder.inplace_subschema_validate(['allOf', i])
end
result_builder.validate(
allOf_results.all?(&:valid?),
'instance is not valid against all schemas specified by `allOf` value',
keyword: 'allOf',
results: allOf_results,
)
else
result_builder.schema_error('`allOf` is not an array', 'allOf')
end
end
end
end
module Schema::Validation::AnyOf
def internal_validate_anyOf(result_builder)
if keyword?('anyOf')
value = schema_content['anyOf']
if value.respond_to?(:to_ary)
anyOf_results = value.each_index.map do |i|
result_builder.inplace_subschema_validate(['anyOf', i])
end
result_builder.validate(
anyOf_results.any?(&:valid?),
'instance is not valid against any schemas specified by `anyOf` value',
keyword: 'anyOf',
results: anyOf_results,
)
else
result_builder.schema_error('`anyOf` is not an array', 'anyOf')
end
end
end
end
module Schema::Validation::OneOf
def internal_validate_oneOf(result_builder)
if keyword?('oneOf')
value = schema_content['oneOf']
if value.respond_to?(:to_ary)
oneOf_results = value.each_index.map do |i|
result_builder.inplace_subschema_validate(['oneOf', i])
end
if oneOf_results.none?(&:valid?)
result_builder.validate(
false,
'instance is not valid against any schemas specified by `oneOf` value',
keyword: 'oneOf',
results: oneOf_results,
)
else
result_builder.validate(
oneOf_results.select(&:valid?).size == 1,
'instance is valid against more than one schema specified by `oneOf` value',
keyword: 'oneOf',
results: oneOf_results,
)
end
else
result_builder.schema_error('`oneOf` is not an array', 'oneOf')
end
end
end
end
end