Class: Schemacop::BaseSchema
- Inherits:
-
Object
- Object
- Schemacop::BaseSchema
- Defined in:
- lib/schemacop/base_schema.rb
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
-
#invalid?(data) ⇒ Boolean
Query data validity.
-
#valid?(data) ⇒ Boolean
Query data validity.
-
#validate!(data) ⇒ Object
Validate data for the defined Schema.
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
3 4 5 |
# File 'lib/schemacop/base_schema.rb', line 3 def root @root end |
Instance Method Details
#invalid?(data) ⇒ Boolean
Query data validity
17 18 19 |
# File 'lib/schemacop/base_schema.rb', line 17 def invalid?(data) !valid?(data) end |
#valid?(data) ⇒ Boolean
Query data validity
9 10 11 |
# File 'lib/schemacop/base_schema.rb', line 9 def valid?(data) validate(data).valid? end |
#validate!(data) ⇒ Object
Validate data for the defined Schema
27 28 29 30 31 32 33 34 35 |
# File 'lib/schemacop/base_schema.rb', line 27 def validate!(data) result = validate(data) unless result.valid? fail Exceptions::ValidationError, result. end return result.data end |