Class: Schemacop::HashValidator
- Inherits:
-
NodeSupportingField
- Object
- Node
- NodeWithBlock
- NodeSupportingField
- Schemacop::HashValidator
- Defined in:
- lib/schemacop/validator/hash_validator.rb
Instance Attribute Summary
Attributes inherited from NodeSupportingField
Attributes inherited from Node
Instance Method Summary collapse
Methods inherited from NodeSupportingField
#initialize, #opt!, #opt?, #req!, #req?
Methods inherited from NodeWithBlock
Methods inherited from Node
build, class_matches?, clear_klasses, clear_symbols, #exec_block, #initialize, klass, option, #option, #option?, register, #resolve_type_klass, symbol, symbol_matches?, #type_filter_matches?, #type_label, type_matches?, #type_matches?
Constructor Details
This class inherits a constructor from Schemacop::NodeSupportingField
Instance Method Details
#validate(data, collector) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/schemacop/validator/hash_validator.rb', line 5 def validate(data, collector) super allowed_fields = @fields.keys obsolete_keys = data.keys - allowed_fields collector.error "Obsolete keys: #{obsolete_keys.inspect}." if obsolete_keys.any? @fields.values.each do |field| field.validate(data, collector) end end |