Class: ValidationManager
- Inherits:
-
Object
- Object
- ValidationManager
- Defined in:
- lib/validation_profiler.rb
Instance Method Summary collapse
-
#validate(obj, profile) ⇒ ValidationManagerResult
Called to validate an object against a validation profile.
Instance Method Details
#validate(obj, profile) ⇒ ValidationManagerResult
Called to validate an object against a validation profile.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/validation_profiler.rb', line 33 def validate(obj, profile) result = ValidationManagerResult.new validation_rules = profile.class_variable_get(:@@validation_rules) validation_rules.each do |r| rule = ValidationRuleManager.instance.get_rule(r[:name]) outcome = rule.validate(obj, r[:field], r[:attributes]) if !outcome result.outcome = false result.errors.push({ field: r[:field], message: rule.(r[:field], r[:attributes]) }) end end result end |