Exception: Uniword::ValidationError
- Defined in:
- lib/uniword/errors.rb
Overview
Raised when element validation fails
Instance Attribute Summary collapse
-
#element ⇒ Element
readonly
The element that failed.
-
#errors ⇒ Array<String>
readonly
The validation errors.
Instance Method Summary collapse
-
#initialize(element, errors) ⇒ ValidationError
constructor
A new instance of ValidationError.
Constructor Details
#initialize(element, errors) ⇒ ValidationError
Returns a new instance of ValidationError.
57 58 59 60 61 62 |
# File 'lib/uniword/errors.rb', line 57 def initialize(element, errors) element_name = element.class.name.split("::").last super("Validation failed for #{element_name}: #{errors.join(', ')}") @element = element @errors = errors end |
Instance Attribute Details
#element ⇒ Element (readonly)
Returns The element that failed.
65 66 67 |
# File 'lib/uniword/errors.rb', line 65 def element @element end |
#errors ⇒ Array<String> (readonly)
Returns The validation errors.
68 69 70 |
# File 'lib/uniword/errors.rb', line 68 def errors @errors end |