Class: Dry::Validation::Result
- Inherits:
-
Object
- Object
- Dry::Validation::Result
- Defined in:
- lib/dry/validation/result.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#rule ⇒ Object
readonly
Returns the value of attribute rule.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #and(other) ⇒ Object
- #failure? ⇒ Boolean
-
#initialize(input, value, rule) ⇒ Result
constructor
A new instance of Result.
- #or(other) ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(input, value, rule) ⇒ Result
Returns a new instance of Result.
33 34 35 36 37 |
# File 'lib/dry/validation/result.rb', line 33 def initialize(input, value, rule) @input = input @value = value @rule = rule end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
13 14 15 |
# File 'lib/dry/validation/result.rb', line 13 def input @input end |
#rule ⇒ Object (readonly)
Returns the value of attribute rule.
13 14 15 |
# File 'lib/dry/validation/result.rb', line 13 def rule @rule end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
13 14 15 |
# File 'lib/dry/validation/result.rb', line 13 def value @value end |
Instance Method Details
#and(other) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/dry/validation/result.rb', line 39 def and(other) if success? other.(input) else self end end |
#failure? ⇒ Boolean
59 60 61 |
# File 'lib/dry/validation/result.rb', line 59 def failure? ! success? end |
#or(other) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/dry/validation/result.rb', line 47 def or(other) if success? self else other.(input) end end |
#success? ⇒ Boolean
55 56 57 |
# File 'lib/dry/validation/result.rb', line 55 def success? @value end |