Class: JSONSkooma::Keywords::Applicator::Items
- Defined in:
- lib/json_skooma/keywords/applicator/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 |
# File 'lib/json_skooma/keywords/applicator/items.rb', line 12 def evaluate(instance, result) prefix_items = result.sibling(instance, "prefixItems") start_index = prefix_items&.schema_node&.length || 0 annotation = nil error = [] instance.each_with_index do |item, index| next if index < start_index if json.evaluate(item, result).passed? annotation = true else error << index # reset to passed for the next iteration result.success end end return result.annotate(annotation) if error.empty? result.failure(error) end |