Module: DataMapper::Validate::ClassMethods

Module | DataMapper::Validate::ClassMethods
In: | lib/dm-validations.rb

### Methods

add_validator_to_context create_context_instance_methods opts_from_validator_args validators

### Included Modules

DataMapper::Validate::ValidatesPresent DataMapper::Validate::ValidatesAbsent DataMapper::Validate::ValidatesIsConfirmed DataMapper::Validate::ValidatesIsPrimitive DataMapper::Validate::ValidatesIsAccepted DataMapper::Validate::ValidatesFormat DataMapper::Validate::ValidatesLength DataMapper::Validate::ValidatesWithin DataMapper::Validate::ValidatesIsNumber DataMapper::Validate::ValidatesWithMethod DataMapper::Validate::ValidatesWithBlock DataMapper::Validate::ValidatesIsUnique DataMapper::Validate::AutoValidate

### Public Instance methods

add_validator_to_context(opts, fields, klazz)

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

create_context_instance_methods(context)

Given a new context create an instance method of valid_for_<context>? which simply calls valid?(context) if it does not already exist

opts_from_validator_args(args, defaults = nil)

Clean up the argument list and return a opts hash, including the merging of any default opts. Set the context to default if none is provided. Also allow :context to be aliased to :on, :when & group

validators()

Return the set of contextual validators or create a new one

[Validate]