validates_with
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0 (0)
- 3.0.9 (-38)
- 3.1.0 (-1)
- 3.2.1 (0)
- 3.2.8 (1)
- 3.2.13 (0)
- 4.0.2 (7)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- What's this?
validates_with(*args, &block)
public
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.