Module | DataMapper::Validate::ClassMethods |
In: |
lib/dm-validations.rb
|
Create a new validator of the given klazz and push it onto the requested context for each of the attributes in the fields list @param [Hash] opts
Options supplied to validation macro, example: {:context=>:default, :maximum=>50, :allow_nil=>true, :message=>nil}
@param [Array<Symbol>] fields
Fields given to validation macro, example: [:first_name, :last_name] in validates_present :first_name, :last_name
@param [Class] klazz
Validator class, example: DataMapper::Validate::LengthValidator
Given a new context create an instance method of valid_for_<context>? which simply calls valid?(context) if it does not already exist