Class: VanillaValidator::Result
- Inherits:
-
Object
- Object
- VanillaValidator::Result
- Defined in:
- lib/vanilla_validator/result.rb
Overview
Result represents the outcome of a validation operation, including validated data and errors.
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#validated ⇒ Object
Returns the value of attribute validated.
Instance Method Summary collapse
- #failed? ⇒ Boolean
-
#initialize(validated, errors = {}) ⇒ Result
constructor
A new instance of Result.
- #success? ⇒ Boolean (also: #valid?)
Constructor Details
#initialize(validated, errors = {}) ⇒ Result
Returns a new instance of Result.
6 7 8 9 |
# File 'lib/vanilla_validator/result.rb', line 6 def initialize(validated, errors = {}) @validated = validated.with_indifferent_access @errors = errors.with_indifferent_access end |
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
4 5 6 |
# File 'lib/vanilla_validator/result.rb', line 4 def errors @errors end |
#validated ⇒ Object
Returns the value of attribute validated.
4 5 6 |
# File 'lib/vanilla_validator/result.rb', line 4 def validated @validated end |
Instance Method Details
#failed? ⇒ Boolean
15 16 17 |
# File 'lib/vanilla_validator/result.rb', line 15 def failed? errors.any? end |
#success? ⇒ Boolean Also known as: valid?
11 12 13 |
# File 'lib/vanilla_validator/result.rb', line 11 def success? errors.empty? end |