Class: Dry::Validation::Error
- Inherits:
-
Object
- Object
- Dry::Validation::Error
- Defined in:
- lib/dry/validation/error.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize(name, result) ⇒ Error
constructor
A new instance of Error.
- #schema? ⇒ Boolean
- #to_ast ⇒ Object
Constructor Details
#initialize(name, result) ⇒ Error
Returns a new instance of Error.
8 9 10 11 |
# File 'lib/dry/validation/error.rb', line 8 def initialize(name, result) @name = name @result = result end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/dry/validation/error.rb', line 6 def name @name end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
6 7 8 |
# File 'lib/dry/validation/error.rb', line 6 def result @result end |
Instance Method Details
#schema? ⇒ Boolean
13 14 15 |
# File 'lib/dry/validation/error.rb', line 13 def schema? result.response.is_a?(Validation::Result) end |
#to_ast ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/dry/validation/error.rb', line 17 def to_ast if schema? [:schema, [name, result.response.to_ast]] else [:error, [name, result.to_ast]] end end |