Class: Reform::Form::Dry::Validations::Group

Inherits:
Object
  • Object
show all
Defined in:
lib/reform/form/dry.rb

Instance Method Summary collapse

Constructor Details

#initializeGroup

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).messages.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