dm-validations/lib/dm-validations.rb
# Create a new validator of the given klazz and push it onto the 
# requested context for each of the fields in the fields list
#
Create a new validator of the given klazz and push it onto the
requested context for each of the fields in the fields list
Create a new validator of the given klazz and push it onto the requested context for each of the fields in the fields list
def add_validator_to_context(opts, fields, klazz)
          fields.each do |field|
            if opts[:context].is_a?(Symbol)
              validators.context(opts[:context]) << klazz.new(field, opts)
              create_context_instance_methods(opts[:context])
            elsif opts[:context].is_a?(Array)
              opts[:context].each do |c| 
                validators.context(c) << klazz.new(field, opts)
                create_context_instance_methods(c)
              end
            end
          end        
        end
def add_validator_to_context ( opts , fields , klazz ) fields . each do | field | if opts [ :context ] . is_a? ( Symbol ) validators . context ( opts [ :context ] ) << klazz . new ( field , opts ) create_context_instance_methods ( opts [ :context ] ) elsif opts [ :context ] . is_a? ( Array ) opts [ :context ] . each do | c | validators . context ( c ) << klazz . new ( field , opts ) create_context_instance_methods ( c ) end end end end
Create a new validator of the given klazz and push it onto the
requested context for each of the fields in the fields list
Create a new validator of the given klazz and push it onto the requested context for each of the fields in the fields list
opts
fields
klazz