Class: Reform::Form::Dry::Validations::Group
- Inherits:
-
Object
- Object
- Reform::Form::Dry::Validations::Group
- Defined in:
- lib/reform/form/dry.rb
Defined Under Namespace
Classes: Builder
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.
27 28 29 |
# File 'lib/reform/form/dry.rb', line 27 def initialize @schemas = [] end |
Instance Method Details
#call(fields, reform_errors, form) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/reform/form/dry.rb', line 36 def call(fields, reform_errors, form) # a message item looks like: {:confirm_password=>["confirm_password size cannot be less than 2"]} @validator.with(form: form).call(fields)..each do |field, dry_error| dry_error.each do |attr_error| reform_errors.add(field, attr_error) end end end |
#instance_exec(&block) ⇒ Object
31 32 33 34 |
# File 'lib/reform/form/dry.rb', line 31 def instance_exec(&block) @schemas << block @validator = Builder.new(@schemas.dup).validation_graph end |