Class: Skooma::Keywords::OAS31::Dialect::Properties

Inherits:
JSONSkooma::Keywords::Applicator::Properties
  • Object
show all
Defined in:
lib/skooma/keywords/oas_3_1/dialect/properties.rb

Instance Method Summary collapse

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
# File 'lib/skooma/keywords/oas_3_1/dialect/properties.rb', line 12

def evaluate(instance, result)
  annotation = []
  err_names = []
  instance.each do |name, item|
    next unless json.value.key?(name)

    result.call(item, name) do |subresult|
      json[name].evaluate(item, subresult)
      if ignored_with_only_key?(subresult)
        subresult.discard
      elsif subresult.passed?
        annotation << name
      else
        err_names << name
      end
    end
  end

  return result.annotate(annotation) if err_names.empty?

  result.failure("Properties #{err_names.join(", ")} are invalid")
end