Exception: JsonSchemaRails::ValidationError
- Defined in:
- lib/json_schema_rails/errors.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(message, schema = nil, errors = nil) ⇒ ValidationError
constructor
A new instance of ValidationError.
Constructor Details
#initialize(message, schema = nil, errors = nil) ⇒ ValidationError
Returns a new instance of ValidationError.
23 24 25 26 27 |
# File 'lib/json_schema_rails/errors.rb', line 23 def initialize(, schema = nil, errors = nil) super() @schema = schema @errors = errors end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
21 22 23 |
# File 'lib/json_schema_rails/errors.rb', line 21 def errors @errors end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
20 21 22 |
# File 'lib/json_schema_rails/errors.rb', line 20 def schema @schema end |
Class Method Details
.from_errors(errors, schema = nil, schema_name = nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/json_schema_rails/errors.rb', line 29 def self.from_errors(errors, schema = nil, schema_name = nil) = "Validation error" << " for schema #{schema_name}" if schema_name errors.each do |err| if err.is_a?(JsonSchema::ValidationError) << "\n- #{err.pointer}: failed schema #{err.schema.pointer}: #{err.}" else << "\n- #{err.schema.pointer}: #{err.}" end end new(, schema, errors) end |