Class: ManyObjectMembersValidation

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

#value_validationObject

Returns the value of attribute value_validation.



842
843
844
# File 'lib/json_patterns.rb', line 842

def value_validation
  @value_validation
end

Instance Method Details

#first_value_match?(name, value) ⇒ Boolean

Returns:



853
854
855
# File 'lib/json_patterns.rb', line 853

def first_value_match?(name, value)
  @value_validation.validate([], value).empty?
end

#first_value_validations(name) ⇒ Object



857
858
859
# File 'lib/json_patterns.rb', line 857

def first_value_validations(name)
  Set[@value_validation]
end

#matching_first_names(data) ⇒ Object



849
850
851
# File 'lib/json_patterns.rb', line 849

def matching_first_names(data)
  Set[*data.keys]
end

#possible_first_namesObject



844
845
846
847
# File 'lib/json_patterns.rb', line 844

def possible_first_names
  # TODO: Need a way to indicate this can match any first names, rather than none
  Set[]
end

#to_sObject



861
862
863
# File 'lib/json_patterns.rb', line 861

def to_s
  "__: #{@value_validation}, ..."
end

#validate_members(path, data) ⇒ Object



865
866
867
868
869
870
871
872
873
874
875
# File 'lib/json_patterns.rb', line 865

def validate_members(path, data)
  failures = []
  data = data.to_a
  for i in 0..(data.length-1)
    failures += @value_validation.validate(path + [data[i][0]], data[i][1])
  end
  return ObjectMembersValidationResult.new(
    failures: failures,
    remainder: {},
  )
end