Module: Reform::Form::Validate
- Included in:
- Reform::Form
- Defined in:
- lib/reform/form/validate.rb
Overview
Mechanics for writing to forms in #validate.
Defined Under Namespace
Modules: Populator, Skip Classes: Changed, DeserializeError
Instance Method Summary collapse
-
#update!(params) ⇒ Object
Some users use this method to pre-populate a form.
-
#validate(params) ⇒ Object
1.
Instance Method Details
#update!(params) ⇒ Object
Some users use this method to pre-populate a form. Not saying this is right, but we’ll keep this method here.
85 86 87 |
# File 'lib/reform/form/validate.rb', line 85 def update!(params) deserialize!(params) end |
#validate(params) ⇒ Object
-
Populate the form object graph so that each incoming object has a representative form object.
-
Deserialize. This is wrong and should be done in 1.
-
Validate the form object graph.
74 75 76 77 78 79 80 81 |
# File 'lib/reform/form/validate.rb', line 74 def validate(params) update!(params) super() # run the actual validation on self. rescue Representable::DeserializeError raise DeserializeError.new("[Reform] Deserialize error: You probably called #validate without setting up your nested models. Check https://github.com/apotonick/reform#populating-forms-for-validation on how to use populators.") end |