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
in the callback
placed on the validates method as these are applied and tested
available on the class version of validates_with, should instead be
Standard configuration options (:on, :if and :unless), which are
end
end
validates_with MyValidator, MyOtherValidator
def instance_validations
validates :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
validates :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! args.each do |klass| validator = klass.new(options, &block) validator.validate(self) end end