Class: NxtSchema::Application::AnyOf

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

Instance Attribute Summary

Attributes inherited from Base

#applied, #applied_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::Application::Base

Instance Method Details

#callObject



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

def call
  # TODO: We should check that this is not empty!
  child_applications.map(&:call)

  if valid?
    self.output = valid_application.output
  else
    child_applications.each do |application|
      merge_errors(application)
    end
  end

  self
end

#valid?Boolean

Returns:

  • (Boolean)


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

def valid?
  valid_application.present?
end