Is there a way to find all defined validations for a model. E.g :
class Temp < ActiveRecord::Base
validate_uniqueness_of :name
validate :some_method
def some_method
...
end
end
When i try :
Temp.validators
It only finds the uniqueness validation, but not the other one.
I've solved it by using :
Model._validate_callbacks.to_a.reject { |validation| validation.filter.to_s.starts_with?('validate_associated_records') }
The 'reject' is used to ignore some default validations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With