Class: JTD::ValidationError
- Inherits:
-
Struct
- Object
- Struct
- JTD::ValidationError
- Defined in:
- lib/jtd/validate.rb
Overview
Represents a single JSON Type Definition validation error.
ValidationError does not extend StandardError; it is not a Ruby exception. It is a plain old Ruby object.
Every ValidationError has two attributes:
-
instance_path
is an array of strings. It represents the path to the part of theinstance
passed to JTD::validate that was rejected. -
schema_path
is an array of strings. It represents the path to the part of theschema
passed to JTD::validate that rejected the instance atinstance_path
.
Instance Attribute Summary collapse
-
#instance_path ⇒ Object
Returns the value of attribute instance_path.
-
#schema_path ⇒ Object
Returns the value of attribute schema_path.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Constructs a new ValidationError from the standard JSON representation of a validation error in JSON Type Definition.
Instance Attribute Details
#instance_path ⇒ Object
Returns the value of attribute instance_path
96 97 98 |
# File 'lib/jtd/validate.rb', line 96 def instance_path @instance_path end |
#schema_path ⇒ Object
Returns the value of attribute schema_path
96 97 98 |
# File 'lib/jtd/validate.rb', line 96 def schema_path @schema_path end |
Class Method Details
.from_hash(hash) ⇒ Object
Constructs a new ValidationError from the standard JSON representation of a validation error in JSON Type Definition.
100 101 102 103 104 105 |
# File 'lib/jtd/validate.rb', line 100 def self.from_hash(hash) instance_path = hash['instancePath'] schema_path = hash['schemaPath'] ValidationError.new(instance_path, schema_path) end |