Class: Schemacop::Schema2
- Inherits:
-
BaseSchema
- Object
- BaseSchema
- Schemacop::Schema2
- Defined in:
- lib/schemacop/schema2.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from BaseSchema
Instance Method Summary collapse
-
#initialize(*args, **kwargs, &block) ⇒ Schema2
constructor
A new instance of Schema2.
-
#validate(data) ⇒ Schemacop::Collector
Validate data for the defined Schema.
Methods inherited from BaseSchema
#invalid?, #valid?, #validate!
Constructor Details
#initialize(*args, **kwargs, &block) ⇒ Schema2
Returns a new instance of Schema2.
3 4 5 6 7 8 |
# File 'lib/schemacop/schema2.rb', line 3 def initialize(*args, **kwargs, &block) super() @root = V2::HashValidator.new do req :root, *args, **kwargs, &block end end |
Instance Method Details
#validate(data) ⇒ Schemacop::Collector
Validate data for the defined Schema
15 16 17 18 19 20 |
# File 'lib/schemacop/schema2.rb', line 15 def validate(data) dupped_data = V2::Dupper.dup_data(data) collector = V2::Collector.new(dupped_data) root.fields[:root].validate({ root: data }, collector.ignore_next_segment) return collector end |