Exception: Rbdantic::ValidationError
- Inherits:
-
StandardError
- Object
- StandardError
- Rbdantic::ValidationError
- Defined in:
- lib/rbdantic/error_detail.rb
Overview
Raised when model validation fails
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #as_json ⇒ Object (also: #to_h)
- #error_count ⇒ Object
-
#initialize(errors) ⇒ ValidationError
constructor
A new instance of ValidationError.
Constructor Details
#initialize(errors) ⇒ ValidationError
Returns a new instance of ValidationError.
32 33 34 35 |
# File 'lib/rbdantic/error_detail.rb', line 32 def initialize(errors) @errors = errors super() end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
30 31 32 |
# File 'lib/rbdantic/error_detail.rb', line 30 def errors @errors end |
Instance Method Details
#as_json ⇒ Object Also known as: to_h
41 42 43 |
# File 'lib/rbdantic/error_detail.rb', line 41 def as_json(*) { errors: @errors.map(&:as_json), error_count: error_count } end |
#error_count ⇒ Object
37 38 39 |
# File 'lib/rbdantic/error_detail.rb', line 37 def error_count @errors.length end |