validators

validators()
Instance Public methods

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
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}>
#    ]
doc_ruby_on_rails
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.