Module: Dry::Transaction::Extra::Steps::Valid::DSL

Defined in:
lib/dry/transaction/extra/steps/valid.rb

Instance Method Summary collapse

Instance Method Details

#valid(validator, name: nil) ⇒ Object



59
60
61
62
63
64
65
66
67
68
# File 'lib/dry/transaction/extra/steps/valid.rb', line 59

def valid(validator, name: nil)
  return super(validator) if validator.is_a?(Symbol)

  method_name = (name || validator.inspect || "validate").to_sym
  define_method method_name do |**|
    validator
  end

  super(method_name)
end