Class: NxtSchema::Node::AnyOf

Inherits:
Base
  • Object
show all
Defined in:
lib/nxt_schema/node/any_of.rb

Instance Attribute Summary

Attributes inherited from Base

#coerced, #coerced_nodes, #context, #error_key, #errors, #index, #input, #locale, #node, #output, #parent, #root

Instance Method Summary collapse

Methods inherited from Base

#add_error, #add_schema_error, #initialize, #merge_errors, #root?, #run_validations, #up

Constructor Details

This class inherits a constructor from NxtSchema::Node::Base

Instance Method Details

#callObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/nxt_schema/node/any_of.rb', line 8

def call
  child_nodes.map(&:call)

  if valid?
    self.output = valid_node.output
  else
    child_nodes.each do |node|
      merge_errors(node)
    end
  end

  self
end

#valid?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/nxt_schema/node/any_of.rb', line 4

def valid?
  valid_node.present?
end