Class: JSONSchemer::Draft202012::Vocab::Applicator::AdditionalProperties
- Inherits:
-
Keyword
- Object
- Keyword
- JSONSchemer::Draft202012::Vocab::Applicator::AdditionalProperties
show all
- Defined in:
- lib/json_schemer/draft202012/vocab/applicator.rb
Constant Summary
Constants included
from Output
Output::FRAGMENT_ENCODE_REGEX
Instance Attribute Summary
Attributes inherited from Keyword
#parent, #parsed, #root, #value
Attributes included from Output
#keyword, #schema
Instance Method Summary
collapse
Methods inherited from Keyword
#absolute_keyword_location, #error_key, #fetch, #initialize, #parsed_schema, #schema_pointer
Methods included from Output
#x_error
Instance Method Details
#error(formatted_instance_location:) ⇒ Object
298
299
300
|
# File 'lib/json_schemer/draft202012/vocab/applicator.rb', line 298
def error(formatted_instance_location:, **)
"object properties at #{formatted_instance_location} do not match `additionalProperties` schema"
end
|
#false_schema_error(formatted_instance_location:) ⇒ Object
302
303
304
|
# File 'lib/json_schemer/draft202012/vocab/applicator.rb', line 302
def false_schema_error(formatted_instance_location:, **)
"object property at #{formatted_instance_location} is a disallowed additional property"
end
|
#parse ⇒ Object
306
307
308
|
# File 'lib/json_schemer/draft202012/vocab/applicator.rb', line 306
def parse
subschema(value)
end
|
#validate(instance, instance_location, keyword_location, context) ⇒ Object
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
|
# File 'lib/json_schemer/draft202012/vocab/applicator.rb', line 310
def validate(instance, instance_location, keyword_location, context)
return result(instance, instance_location, keyword_location, true) unless instance.is_a?(Hash)
evaluated_keys = context.adjacent_results[Properties]&.annotation || []
evaluated_keys += context.adjacent_results[PatternProperties]&.annotation || []
evaluated_keys = evaluated_keys.to_set
evaluated = instance.reject do |key, _value|
evaluated_keys.include?(key)
end
nested = evaluated.map do |key, value|
parsed.validate_instance(value, join_location(instance_location, key), keyword_location, context)
end
result(instance, instance_location, keyword_location, nested.all?(&:valid), nested, :annotation => evaluated.keys)
end
|