Module: Reform::Contract::Validate
- Included in:
- Reform::Contract
- Defined in:
- lib/reform/contract/validate.rb
Instance Method Summary collapse
Instance Method Details
#validate ⇒ Object
2 3 4 5 6 7 8 9 10 |
# File 'lib/reform/contract/validate.rb', line 2 def validate = {:errors => errs = Reform::Contract::Errors.new(self), :prefix => []} validate!() self.errors = errs # if the AM valid? API wouldn't use a "global" variable this would be better. errors.valid? end |
#validate!(options) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/reform/contract/validate.rb', line 12 def validate!() prefix = [:prefix] # call valid? recursively and collect nested errors. valid_representer.new(fields).to_hash() # TODO: only include nested forms here. valid? # this validates on <Fields> using AM::Validations, currently. [:errors].merge!(self.errors, prefix) end |