Class: Schemacop::V3::AnyOfNode

Inherits:
CombinationNode show all
Defined in:
lib/schemacop/v3/any_of_node.rb

Instance Attribute Summary

Attributes inherited from Node

#as, #default, #description, #name, #options, #parent, #require_key, #title

Instance Method Summary collapse

Methods inherited from CombinationNode

#add_child, #as_json, #cast, dsl_methods, #init

Methods inherited from Node

allowed_options, #allowed_types, #as_json, #cast, #children, create, #create, dsl_methods, #dsl_node, #dsl_scm, #init, #initialize, #require_key?, #required?, resolve_class, #schemas, supports_children, supports_children_options, #used_external_schemas, #validate

Constructor Details

This class inherits a constructor from Schemacop::V3::Node

Instance Method Details

#_validate(data, result:) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/schemacop/v3/any_of_node.rb', line 8

def _validate(data, result:)
  super_data = super
  return if super_data.nil?

  match = match(super_data)

  if match
    match._validate(super_data, result: result)
  else
    result.error <<~PLAIN.strip
      Matches 0 schemas but should match at least 1:
      #{schema_messages(super_data).join("\n")}
    PLAIN
  end
end

#typeObject



4
5
6
# File 'lib/schemacop/v3/any_of_node.rb', line 4

def type
  :anyOf
end

#validate_selfObject



24
25
26
27
28
# File 'lib/schemacop/v3/any_of_node.rb', line 24

def validate_self
  if @items.empty?
    fail 'Node "any_of" makes only sense with at least 1 item.'
  end
end