Passes the record off to the class or classes specified and allows them to add errors based on more complex conditions.
class Person
include ActiveModel::Validations
validate :instance_validations
def instance_validations
validates_with MyValidator
end
end
Please consult the class method documentation for more information on creating your own validator.
You may also pass it multiple classes, like so:
class Person
include ActiveModel::Validations
validate :instance_validations, on: :create
def instance_validations
validates_with MyValidator, MyOtherValidator
end
end
Standard configuration options (:on, :if and
:unless), which are available on the class version of
validates_with, should instead be placed on the
validates method as these are applied and tested in the
callback.
If you pass any additional configuration options, they will be passed to
the class and available as options, please refer to the class
version of this method for more information.
Please login to continue.