aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/validations.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/lib/active_model/validations.rb')
-rw-r--r--activemodel/lib/active_model/validations.rb17
1 files changed, 15 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb
index 611e9ffd55..93b830dd9c 100644
--- a/activemodel/lib/active_model/validations.rb
+++ b/activemodel/lib/active_model/validations.rb
@@ -38,7 +38,6 @@ module ActiveModel
# Note that <tt>ActiveModel::Validations</tt> automatically adds an +errors+ method
# to your instances initialized with a new <tt>ActiveModel::Errors</tt> object, so
# there is no need for you to do this manually.
- #
module Validations
extend ActiveSupport::Concern
@@ -154,6 +153,21 @@ module ActiveModel
# 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
+ #
+ # User.validators
+ # # => [
+ # # #<MyValidator:0x007fbff403e808 @options={}>,
+ # # #<OtherValidator:0x007fbff403d930 @options={:on=>:create}>,
+ # # #<StrictValidator:0x007fbff3204a30 @options={:strict=>true}>
+ # # ]
def validators
_validators.values.flatten.uniq
end
@@ -222,7 +236,6 @@ module ActiveModel
# @data[key]
# end
# end
- #
alias :read_attribute_for_validation :send
protected