Class | DataMapper::Validate::GenericValidator |
In: |
lib/dm-validations/generic_validator.rb
|
Parent: | Object |
All validators extend this base class. Validators must:
@author Guy van den Berg @since 0.9
field_name | [R] | |
if_clause | [RW] | |
unless_clause | [RW] |
Construct a validator. Capture the :if and :unless clauses when present.
@param field<String, Symbol> The property specified for validation
@option :if<Symbol, Proc> The name of a method or a Proc to call to
determine if the validation should occur.
@option :unless<Symbol, Proc> The name of a method or a Proc to call to
determine if the validation should not occur
All additional key/value pairs are passed through to the validator that is sub-classing this GenericValidator
Add an error message to a target resource. If the error corresponds to a specific field of the resource, add it to that field, otherwise add it as a :general message.
@param <Object> target the resource that has the error @param <String> message the message to add @param <Symbol> field_name the name of the field that caused the error
TODO - should the field_name for a general message be :default???
Determines if this validator should be run against the target by evaluating the :if and :unless clauses optionally passed while specifying any validator.
@param <Object> target the resource that we check against @return <Boolean> true if should be run, otherwise false