Class: Dry::Validation::Failures
- Inherits:
-
Object
- Object
- Dry::Validation::Failures
- Defined in:
- lib/dry/validation/failures.rb
Overview
Failure accumulator object
Instance Attribute Summary collapse
-
#opts ⇒ Hash
readonly
private
Options for messages.
-
#path ⇒ Dry::Schema::Path
readonly
private
The path for messages accumulated by failures object.
Instance Method Summary collapse
-
#failure(message, tokens = EMPTY_HASH) ⇒ Object
Set failure.
-
#initialize(path = ROOT_PATH) ⇒ Failures
constructor
private
A new instance of Failures.
Constructor Details
#initialize(path = ROOT_PATH) ⇒ Failures
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Failures.
29 30 31 32 |
# File 'lib/dry/validation/failures.rb', line 29 def initialize(path = ROOT_PATH) @path = Dry::Schema::Path[path] @opts = EMPTY_ARRAY.dup end |
Instance Attribute Details
#opts ⇒ Hash (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Options for messages
These options are used by MessageResolver
26 27 28 |
# File 'lib/dry/validation/failures.rb', line 26 def opts @opts end |
#path ⇒ Dry::Schema::Path (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The path for messages accumulated by failures object
17 18 19 |
# File 'lib/dry/validation/failures.rb', line 17 def path @path end |
Instance Method Details
#failure(message) ⇒ Object #failure(id) ⇒ Object #failure(meta_hash) ⇒ Object
Set failure
59 60 61 62 |
# File 'lib/dry/validation/failures.rb', line 59 def failure(, tokens = EMPTY_HASH) opts << { message: , tokens: tokens, path: path } self end |