module ActiveModel::Validations::ClassMethods
def clear_validators!
Person._validate_callbacks.empty? # => true
so that:
Also, the callback set by validate :cannot_be_robot will be erased
Person.validators # => []
validators this class has, you would obtain:
If one runs Person.clear_validators! and then checks to see what
# ]
# #
# #
# #
# => [
Person.validators
end
end
errors.add(:base, 'A person cannot be a robot') if person_is_robot
def cannot_be_robot
validate :cannot_be_robot
validates_with StrictValidator, strict: true
validates_with OtherValidator, on: :create
validates_with MyValidator
include ActiveModel::Validations
class Person
of +validate+.
+validates_with+ and the callbacks that are set by an invocation
It clears the validators that are created with an invocation of
the model for both the +validates_with+ and +validate+ methods.
Note that this will clear anything that is being used to validate
Clears all of the validators and validations.
def clear_validators! reset_callbacks(:validate) _validators.clear end