Module: Reform::Contract::Validate

Included in:
Reform::Contract
Defined in:
lib/reform/contract/validate.rb

Instance Method Summary collapse

Instance Method Details

#errorsObject



18
19
20
# File 'lib/reform/contract/validate.rb', line 18

def errors
  @errors ||= build_errors
end

#validateObject



2
3
4
5
6
7
# File 'lib/reform/contract/validate.rb', line 2

def validate
  validate!(errs=build_errors, [])

  @errors = errs
  errors.empty?
end

#validate!(errors, prefix) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/reform/contract/validate.rb', line 9

def validate!(errors, prefix)
  validate_nested!(nested_errors = build_errors, prefix) # call valid? recursively and collect nested errors.

  valid?  # calls AM/Lotus validators and invokes self.errors=.

  errors.merge!(self.errors, prefix) # local errors.
  errors.merge!(nested_errors, [])
end