module JSI
module Schema::Validation::Required
def internal_validate_required(result_builder)
if keyword?('required')
value = schema_content['required']
if value.respond_to?(:to_ary)
if result_builder.instance.respond_to?(:to_hash)
missing_required = value.reject { |property_name| result_builder.instance.key?(property_name) }
result_builder.validate(
missing_required.empty?,
'instance object does not contain all property names specified by `required` value',
keyword: 'required',
)
end
else
result_builder.schema_error('`required` is not an array', 'required')
end
end
end
end
end