Method: ActiveModel::Validations::ClassMethods#validators

Defined in:
activemodel/lib/active_model/validations.rb

#validatorsObject

List all validators that are being used to validate the model using validates_with method.

class Person
  include ActiveModel::Validations

  validates_with MyValidator
  validates_with OtherValidator, on: :create
  validates_with StrictValidator, strict: true
end

Person.validators
# => [
#      #<MyValidator:0x007fbff403e808 @options={}>,
#      #<OtherValidator:0x007fbff403d930 @options={on: :create}>,
#      #<StrictValidator:0x007fbff3204a30 @options={strict:true}>
#    ]


206
207
208
# File 'activemodel/lib/active_model/validations.rb', line 206

def validators
  _validators.values.flatten.uniq
end