Class: Dry::Validation::Rule
- Inherits:
-
Object
- Object
- Dry::Validation::Rule
- Defined in:
- lib/dry/validation/rule.rb
Defined Under Namespace
Classes: Composite, Conjunction, Disjunction, Each, Key, Set, Value
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#predicate ⇒ Object
readonly
Returns the value of attribute predicate.
Instance Method Summary collapse
- #and(other) ⇒ Object (also: #&)
- #curry(*args) ⇒ Object
-
#initialize(name, predicate) ⇒ Rule
constructor
A new instance of Rule.
- #or(other) ⇒ Object (also: #|)
- #to_ary ⇒ Object (also: #to_a)
Constructor Details
#initialize(name, predicate) ⇒ Rule
Returns a new instance of Rule.
100 101 102 103 |
# File 'lib/dry/validation/rule.rb', line 100 def initialize(name, predicate) @name = name @predicate = predicate end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
98 99 100 |
# File 'lib/dry/validation/rule.rb', line 98 def name @name end |
#predicate ⇒ Object (readonly)
Returns the value of attribute predicate.
98 99 100 |
# File 'lib/dry/validation/rule.rb', line 98 def predicate @predicate end |
Instance Method Details
#and(other) ⇒ Object Also known as: &
110 111 112 |
# File 'lib/dry/validation/rule.rb', line 110 def and(other) Conjunction.new(self, other) end |
#curry(*args) ⇒ Object
120 121 122 |
# File 'lib/dry/validation/rule.rb', line 120 def curry(*args) self.class.new(name, predicate.curry(*args)) end |
#or(other) ⇒ Object Also known as: |
115 116 117 |
# File 'lib/dry/validation/rule.rb', line 115 def or(other) Disjunction.new(self, other) end |
#to_ary ⇒ Object Also known as: to_a
105 106 107 |
# File 'lib/dry/validation/rule.rb', line 105 def to_ary [type, [name, predicate.to_ary]] end |