Class: SequencedObjectMembersValidation

Inherits:
ObjectMembersValidation show all
Defined in:
lib/json_patterns.rb

Constant Summary

Constants included from Inspectable

Inspectable::INSPECTING_KEY

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ObjectMembersValidation

memoized_new_from_pattern

Methods included from HashInitialized

#initialize

Methods included from Inspectable

#inspect

Instance Attribute Details

#leftObject

TODO: Use an array instead of :left and :right. Easier to process, easier to inspect.

Obviates the need for an EmptyObjectMembersValidation in some cases.


693
694
695
# File 'lib/json_patterns.rb', line 693

def left
  @left
end

#rightObject

TODO: Use an array instead of :left and :right. Easier to process, easier to inspect.

Obviates the need for an EmptyObjectMembersValidation in some cases.


693
694
695
# File 'lib/json_patterns.rb', line 693

def right
  @right
end

Instance Method Details

#first_value_match?(name, value) ⇒ Boolean

Returns:



707
708
709
# File 'lib/json_patterns.rb', line 707

def first_value_match?(name, value)
  @left.first_value_match?(name, value)
end

#first_value_validationObject



699
700
701
# File 'lib/json_patterns.rb', line 699

def first_value_validation
  @left.first_value_validation
end

#first_value_validations(name) ⇒ Object



711
712
713
# File 'lib/json_patterns.rb', line 711

def first_value_validations(name)
  @left.first_value_validations(name)
end

#matching_first_names(data) ⇒ Object



703
704
705
# File 'lib/json_patterns.rb', line 703

def matching_first_names(data)
  @left.matching_first_names(data)
end

#possible_first_namesObject



695
696
697
# File 'lib/json_patterns.rb', line 695

def possible_first_names
  @left.possible_first_names
end

#to_sObject



724
725
726
# File 'lib/json_patterns.rb', line 724

def to_s
  [@left.to_s, @right.to_s].select { |s| not s.empty? }.join(', ')
end

#validate_members(path, data) ⇒ Object



715
716
717
718
719
720
721
722
# File 'lib/json_patterns.rb', line 715

def validate_members(path, data)
  result_left = @left.validate_members(path, data)
  result_right = @right.validate_members(path, result_left.remainder)
  return ObjectMembersValidationResult.new(
    failures: result_left.failures + result_right.failures,
    remainder: result_right.remainder,
  )
end