Class: Dry::Validation::Schema::Result
- Inherits:
-
Object
- Object
- Dry::Validation::Schema::Result
- Includes:
- Enumerable
- Defined in:
- lib/dry/validation/schema/result.rb
Instance Attribute Summary collapse
-
#error_compiler ⇒ Object
readonly
Returns the value of attribute error_compiler.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
- #failures ⇒ Object
-
#initialize(params, result, errors, error_compiler) ⇒ Result
constructor
A new instance of Result.
- #messages(options = {}) ⇒ Object
- #successes ⇒ Object
- #to_ary ⇒ Object
Constructor Details
#initialize(params, result, errors, error_compiler) ⇒ Result
Returns a new instance of Result.
15 16 17 18 19 20 |
# File 'lib/dry/validation/schema/result.rb', line 15 def initialize(params, result, errors, error_compiler) @params = params @result = result @errors = errors @error_compiler = error_compiler end |
Instance Attribute Details
#error_compiler ⇒ Object (readonly)
Returns the value of attribute error_compiler.
13 14 15 |
# File 'lib/dry/validation/schema/result.rb', line 13 def error_compiler @error_compiler end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
11 12 13 |
# File 'lib/dry/validation/schema/result.rb', line 11 def errors @errors end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
7 8 9 |
# File 'lib/dry/validation/schema/result.rb', line 7 def params @params end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
9 10 11 |
# File 'lib/dry/validation/schema/result.rb', line 9 def result @result end |
Instance Method Details
#each(&block) ⇒ Object
22 23 24 |
# File 'lib/dry/validation/schema/result.rb', line 22 def each(&block) failures.each(&block) end |
#empty? ⇒ Boolean
26 27 28 |
# File 'lib/dry/validation/schema/result.rb', line 26 def empty? errors.empty? end |
#failures ⇒ Object
42 43 44 |
# File 'lib/dry/validation/schema/result.rb', line 42 def failures result.failures end |
#messages(options = {}) ⇒ Object
34 35 36 |
# File 'lib/dry/validation/schema/result.rb', line 34 def ( = {}) @messages ||= error_compiler.with().(errors.map(&:to_ary)) end |
#successes ⇒ Object
38 39 40 |
# File 'lib/dry/validation/schema/result.rb', line 38 def successes result.successes end |
#to_ary ⇒ Object
30 31 32 |
# File 'lib/dry/validation/schema/result.rb', line 30 def to_ary errors.map(&:to_ary) end |