Module: Reform::Contract::Validate
- Included in:
- Reform::Contract
- Defined in:
- lib/reform/contract/validate.rb
Defined Under Namespace
Modules: NestedValid
Instance Method Summary collapse
Instance Method Details
#validate ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/reform/contract/validate.rb', line 27 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
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/reform/contract/validate.rb', line 36 def validate!() # puts "validate! in #{self.class.name}: #{true.inspect}" prefix = [:prefix] # call valid? recursively and collect nested errors. mapper.new(fields).extend(NestedValid).to_hash() # TODO: only include nested forms here. valid? # this validates on <Fields> using AM::Validations, currently. [:errors].merge!(self.errors, prefix) end |