module JSI
module Schema::Validation::MinMaxProperties
def internal_validate_maxProperties(result_builder)
if keyword?('maxProperties')
value = schema_content['maxProperties']
if internal_integer?(value) && value >= 0
if result_builder.instance.respond_to?(:to_hash)
result_builder.validate(
result_builder.instance.size <= value,
'instance object contains more properties than `maxProperties` value',
keyword: 'maxProperties',
)
end
else
result_builder.schema_error('`maxProperties` is not a non-negative integer', 'maxProperties')
end
end
end
def internal_validate_minProperties(result_builder)
if keyword?('minProperties')
value = schema_content['minProperties']
if internal_integer?(value) && value >= 0
if result_builder.instance.respond_to?(:to_hash)
result_builder.validate(
result_builder.instance.size >= value,
'instance object contains fewer properties than `minProperties` value',
keyword: 'minProperties',
)
end
else
result_builder.schema_error('`minProperties` is not a non-negative integer', 'minProperties')
end
end
end
end
end