Class: Reform::Form::Dry::Validations::Group
- Inherits:
-
Object
- Object
- Reform::Form::Dry::Validations::Group
- Defined in:
- lib/reform/form/dry.rb
Instance Method Summary collapse
- #call(fields, reform_errors, form) ⇒ Object
-
#initialize ⇒ Group
constructor
A new instance of Group.
- #instance_exec(&block) ⇒ Object
Constructor Details
#initialize ⇒ Group
Returns a new instance of Group.
23 24 25 |
# File 'lib/reform/form/dry.rb', line 23 def initialize @validator = Class.new(ValidatorSchema) end |
Instance Method Details
#call(fields, reform_errors, form) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/reform/form/dry.rb', line 31 def call(fields, reform_errors, form) validator = @validator.new(form) # a message item looks like: {:confirm_password=>[["confirm_password size cannot be less than 2"], "9"]} validator.call(fields)..each do |field, dry_error| dry_error[0].each do |attr_error| reform_errors.add(field, attr_error) end end end |
#instance_exec(&block) ⇒ Object
27 28 29 |
# File 'lib/reform/form/dry.rb', line 27 def instance_exec(&block) @validator.class_eval(&block) end |