Class: Reform::Validation::Groups::Validate
- Inherits:
-
Object
- Object
- Reform::Validation::Groups::Validate
- Defined in:
- lib/reform/validation/groups.rb
Overview
Runs all validations groups according to their rules and returns all Result objects.
Class Method Summary collapse
Class Method Details
.call(groups, form) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/reform/validation/groups.rb', line 41 def self.call(groups, form) results = {} groups.collect do |(name, group, )| next unless evaluate?([:if], results, form) results[name] = group.(form) # run validation for group. store and collect <Result>. end end |
.evaluate?(depends_on, results, form) ⇒ Boolean
50 51 52 53 54 |
# File 'lib/reform/validation/groups.rb', line 50 def self.evaluate?(depends_on, results, form) return true if depends_on.nil? return !results[depends_on].nil? && results[depends_on].success? if depends_on.is_a?(Symbol) form.instance_exec(results, &depends_on) end |