Class: OptionalObjectMembersValidation

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

#membersObject

Returns the value of attribute members.



798
799
800
# File 'lib/json_patterns.rb', line 798

def members
  @members
end

Instance Method Details

#first_value_match?(name, value) ⇒ Boolean

Returns:



810
811
812
# File 'lib/json_patterns.rb', line 810

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

#first_value_validations(name) ⇒ Object



814
815
816
# File 'lib/json_patterns.rb', line 814

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

#matching_first_names(data) ⇒ Object



806
807
808
# File 'lib/json_patterns.rb', line 806

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

#possible_first_namesObject

TODO: If this is in a sequence, failure should trigger a check to the next member in the sequence



802
803
804
# File 'lib/json_patterns.rb', line 802

def possible_first_names
  @members.possible_first_names
end

#to_sObject



829
830
831
# File 'lib/json_patterns.rb', line 829

def to_s
  "(#{@members})?"
end

#validate_members(path, data) ⇒ Object



818
819
820
821
822
823
824
825
826
827
# File 'lib/json_patterns.rb', line 818

def validate_members(path, data)
  if matching_first_names(data).size > 0
    return @members.validate_members(path, data)
  else
    return ObjectMembersValidationResult.new(
      failures: [],
      remainder: data,
    )
  end
end