Class: Dry::Validation::ApplyRules

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/validation/executor.rb

Direct Known Subclasses

ApplyChecks

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rules) ⇒ ApplyRules

Returns a new instance of ApplyRules.



32
33
34
# File 'lib/dry/validation/executor.rb', line 32

def initialize(rules)
  @rules = rules
end

Instance Attribute Details

#rulesObject (readonly)

Returns the value of attribute rules.



30
31
32
# File 'lib/dry/validation/executor.rb', line 30

def rules
  @rules
end

Instance Method Details

#call(input, result) ⇒ Object



36
37
38
39
40
41
# File 'lib/dry/validation/executor.rb', line 36

def call(input, result)
  rules.each_with_object(result) do |(name, rule), hash|
    hash[name] = rule.(input)
  end
  input
end