Class: Dry::Validation::Rule::Result
- Inherits:
-
Object
- Object
- Dry::Validation::Rule::Result
- Defined in:
- lib/dry/validation/rule/result.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#rule ⇒ Object
readonly
Returns the value of attribute rule.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #>(other) ⇒ Object
- #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 38 |
# File 'lib/dry/validation/rule/result.rb', line 33 def initialize(input, value, rule) @input = input @value = value @rule = rule @name = rule.name end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
13 14 15 |
# File 'lib/dry/validation/rule/result.rb', line 13 def input @input end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/dry/validation/rule/result.rb', line 13 def name @name end |
#rule ⇒ Object (readonly)
Returns the value of attribute rule.
13 14 15 |
# File 'lib/dry/validation/rule/result.rb', line 13 def rule @rule end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
13 14 15 |
# File 'lib/dry/validation/rule/result.rb', line 13 def value @value end |
Instance Method Details
#>(other) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/dry/validation/rule/result.rb', line 40 def >(other) if success? other.(input) else Validation.Result(input, true, rule) end end |
#and(other) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/dry/validation/rule/result.rb', line 48 def and(other) if success? other.(input) else self end end |
#failure? ⇒ Boolean
68 69 70 |
# File 'lib/dry/validation/rule/result.rb', line 68 def failure? ! success? end |
#or(other) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/dry/validation/rule/result.rb', line 56 def or(other) if success? self else other.(input) end end |
#success? ⇒ Boolean
64 65 66 |
# File 'lib/dry/validation/rule/result.rb', line 64 def success? @value end |