Class: JSI::Validation::Error
- Inherits:
-
Object
- Object
- JSI::Validation::Error
- Defined in:
- lib/jsi/validation/error.rb
Overview
a validation error of a schema instance against a schema
Instance Attribute Summary collapse
-
#additional ⇒ Hash
additional contextual information about the error.
-
#instance_document ⇒ Object
document containing the instance at instance_ptr.
-
#instance_ptr ⇒ JSI::Ptr
pointer to the instance in instance_document.
-
#keyword ⇒ String
the keyword of the schema which failed to validate.
-
#message ⇒ String
a message describing the error.
- #nested_errors ⇒ Set<Validation::Error>
-
#schema ⇒ JSI::Schema
the schema against which the instance failed to validate.
Instance Method Summary collapse
- #each_validation_error {|Validation::Error| ... } ⇒ Object
-
#initialize(attributes = {}) ⇒ Error
constructor
A new instance of Error.
- #instance ⇒ Object
- #pretty_print(q) ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Error
Returns a new instance of Error.
39 40 41 42 |
# File 'lib/jsi/validation/error.rb', line 39 def initialize(attributes = {}) super freeze end |
Instance Attribute Details
#additional ⇒ Hash
additional contextual information about the error
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/jsi/validation/error.rb', line 38 class Error def initialize(attributes = {}) super freeze end # @yield [Validation::Error] def each_validation_error(&block) return(to_enum(__method__)) if !block_given? nested_errors.each { |nested_error| nested_error.each_validation_error(&block) } yield(self) nil end # @return [Object] def instance instance_ptr.evaluate(instance_document) end def pretty_print(q) info = { message: , instance: instance, instance_ptr: instance_ptr, keyword: keyword, additional: additional, 'schema uri': schema.schema_uri || schema.jsi_ptr.uri, nested_errors: nested_errors, } jsi_pp_object_group(q) do q.seplist(info) do |k, v| q.text(k.to_s) q.text(': ') q.pp(v) end end end end |
#instance_document ⇒ Object
document containing the instance at instance_ptr
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/jsi/validation/error.rb', line 38 class Error def initialize(attributes = {}) super freeze end # @yield [Validation::Error] def each_validation_error(&block) return(to_enum(__method__)) if !block_given? nested_errors.each { |nested_error| nested_error.each_validation_error(&block) } yield(self) nil end # @return [Object] def instance instance_ptr.evaluate(instance_document) end def pretty_print(q) info = { message: , instance: instance, instance_ptr: instance_ptr, keyword: keyword, additional: additional, 'schema uri': schema.schema_uri || schema.jsi_ptr.uri, nested_errors: nested_errors, } jsi_pp_object_group(q) do q.seplist(info) do |k, v| q.text(k.to_s) q.text(': ') q.pp(v) end end end end |
#instance_ptr ⇒ JSI::Ptr
pointer to the instance in instance_document
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/jsi/validation/error.rb', line 38 class Error def initialize(attributes = {}) super freeze end # @yield [Validation::Error] def each_validation_error(&block) return(to_enum(__method__)) if !block_given? nested_errors.each { |nested_error| nested_error.each_validation_error(&block) } yield(self) nil end # @return [Object] def instance instance_ptr.evaluate(instance_document) end def pretty_print(q) info = { message: , instance: instance, instance_ptr: instance_ptr, keyword: keyword, additional: additional, 'schema uri': schema.schema_uri || schema.jsi_ptr.uri, nested_errors: nested_errors, } jsi_pp_object_group(q) do q.seplist(info) do |k, v| q.text(k.to_s) q.text(': ') q.pp(v) end end end end |
#keyword ⇒ String
the keyword of the schema which failed to validate.
this may be absent if the error is not from a schema keyword (i.e, false schema).
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/jsi/validation/error.rb', line 38 class Error def initialize(attributes = {}) super freeze end # @yield [Validation::Error] def each_validation_error(&block) return(to_enum(__method__)) if !block_given? nested_errors.each { |nested_error| nested_error.each_validation_error(&block) } yield(self) nil end # @return [Object] def instance instance_ptr.evaluate(instance_document) end def pretty_print(q) info = { message: , instance: instance, instance_ptr: instance_ptr, keyword: keyword, additional: additional, 'schema uri': schema.schema_uri || schema.jsi_ptr.uri, nested_errors: nested_errors, } jsi_pp_object_group(q) do q.seplist(info) do |k, v| q.text(k.to_s) q.text(': ') q.pp(v) end end end end |
#message ⇒ String
a message describing the error
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/jsi/validation/error.rb', line 38 class Error def initialize(attributes = {}) super freeze end # @yield [Validation::Error] def each_validation_error(&block) return(to_enum(__method__)) if !block_given? nested_errors.each { |nested_error| nested_error.each_validation_error(&block) } yield(self) nil end # @return [Object] def instance instance_ptr.evaluate(instance_document) end def pretty_print(q) info = { message: , instance: instance, instance_ptr: instance_ptr, keyword: keyword, additional: additional, 'schema uri': schema.schema_uri || schema.jsi_ptr.uri, nested_errors: nested_errors, } jsi_pp_object_group(q) do q.seplist(info) do |k, v| q.text(k.to_s) q.text(': ') q.pp(v) end end end end |
#nested_errors ⇒ Set<Validation::Error>
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/jsi/validation/error.rb', line 38 class Error def initialize(attributes = {}) super freeze end # @yield [Validation::Error] def each_validation_error(&block) return(to_enum(__method__)) if !block_given? nested_errors.each { |nested_error| nested_error.each_validation_error(&block) } yield(self) nil end # @return [Object] def instance instance_ptr.evaluate(instance_document) end def pretty_print(q) info = { message: , instance: instance, instance_ptr: instance_ptr, keyword: keyword, additional: additional, 'schema uri': schema.schema_uri || schema.jsi_ptr.uri, nested_errors: nested_errors, } jsi_pp_object_group(q) do q.seplist(info) do |k, v| q.text(k.to_s) q.text(': ') q.pp(v) end end end end |
#schema ⇒ JSI::Schema
the schema against which the instance failed to validate
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/jsi/validation/error.rb', line 38 class Error def initialize(attributes = {}) super freeze end # @yield [Validation::Error] def each_validation_error(&block) return(to_enum(__method__)) if !block_given? nested_errors.each { |nested_error| nested_error.each_validation_error(&block) } yield(self) nil end # @return [Object] def instance instance_ptr.evaluate(instance_document) end def pretty_print(q) info = { message: , instance: instance, instance_ptr: instance_ptr, keyword: keyword, additional: additional, 'schema uri': schema.schema_uri || schema.jsi_ptr.uri, nested_errors: nested_errors, } jsi_pp_object_group(q) do q.seplist(info) do |k, v| q.text(k.to_s) q.text(': ') q.pp(v) end end end end |
Instance Method Details
#each_validation_error {|Validation::Error| ... } ⇒ Object
45 46 47 48 49 50 |
# File 'lib/jsi/validation/error.rb', line 45 def each_validation_error(&block) return(to_enum(__method__)) if !block_given? nested_errors.each { |nested_error| nested_error.each_validation_error(&block) } yield(self) nil end |
#instance ⇒ Object
53 54 55 |
# File 'lib/jsi/validation/error.rb', line 53 def instance instance_ptr.evaluate(instance_document) end |
#pretty_print(q) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/jsi/validation/error.rb', line 57 def pretty_print(q) info = { message: , instance: instance, instance_ptr: instance_ptr, keyword: keyword, additional: additional, 'schema uri': schema.schema_uri || schema.jsi_ptr.uri, nested_errors: nested_errors, } jsi_pp_object_group(q) do q.seplist(info) do |k, v| q.text(k.to_s) q.text(': ') q.pp(v) end end end |