Class: JSONSkooma::Keywords::Draft201909::AdditionalItems
- Defined in:
- lib/json_skooma/keywords/draft_2019_09/additional_items.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#each_schema, inherited, #initialize, #instance_types, #key, #resolve, set_defaults, #static, value_schema=
Constructor Details
This class inherits a constructor from JSONSkooma::Keywords::Base
Instance Method Details
#evaluate(instance, result) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/json_skooma/keywords/draft_2019_09/additional_items.rb', line 12 def evaluate(instance, result) items = result.sibling(instance, "items") return result.discard unless items&.annotation.is_a?(Integer) annotation = nil error = [] instance.each_with_index do |item, index| next if items.annotation >= index if json.evaluate(item, result).passed? annotation = true else error << index # reset to passed for the next iteration result.success end end if error.any? result.failure(error) else result.annotate(annotation) end end |