Module: ErrorProne::Validator::ClassMethods
- Defined in:
- lib/error_prone.rb
Instance Method Summary collapse
-
#rules ⇒ ErrorProne::RuleSet
Contains rules the validator will run when .validate! is called.
-
#validate!(object) ⇒ Boolean
Validates all rules against the given object.
-
#validates(field, rule, options = {}) ⇒ Object
Adds a rule the validator runs when .validate! is called.
Instance Method Details
#rules ⇒ ErrorProne::RuleSet
Contains rules the validator will run when .validate! is called
133 134 135 |
# File 'lib/error_prone.rb', line 133 def rules @rules ||= RuleSet.new end |
#validate!(object) ⇒ Boolean
Validates all rules against the given object
151 152 153 |
# File 'lib/error_prone.rb', line 151 def validate!(object) rules.all_valid_for? object end |
#validates(field, rule, options = {}) ⇒ Object
Adds a rule the validator runs when .validate! is called.
143 144 145 |
# File 'lib/error_prone.rb', line 143 def validates(field, rule, ={}) rules.add(field, rule, ) end |