module ActiveModel::Validations

def validates_with(*args, &block)

class version of this method for more information.
to the class and available as +options+, please refer to the
If you pass any additional configuration options, they will be passed

as these are applied and tested in the callback.
+validates_with+, should instead be placed on the +validates+ method
:unless), which are available on the class version of
Standard configuration options (:on, :if and

end
end
validates_with MyValidator, MyOtherValidator
def instance_validations

validate :instance_validations, on: :create

include ActiveModel::Validations
class Person

You may also pass it multiple classes, like so:

creating your own validator.
Please consult the class method documentation for more information on

end
end
validates_with MyValidator
def instance_validations

validate :instance_validations

include ActiveModel::Validations
class Person

to add errors based on more complex conditions.
Passes the record off to the class or classes specified and allows them
def validates_with(*args, &block)
  options = args.extract_options!
  options[:class] = self.class
  args.each do |klass|
    validator = klass.new(options, &block)
    validator.validate(self)
  end
end