aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/validations.rb
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2012-06-22 22:15:27 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2012-06-22 22:15:27 +0530
commit35ee8fa3d8b3ad49179f86af2bec2e53af335ac9 (patch)
tree5929e772a461c683c54c1fd66b303516e5d0df33 /activemodel/lib/active_model/validations.rb
parentfb8cf55868d555b7f06215db5976c8aaf083d30b (diff)
parent6285675db1cf983ba6c15442aedb457c8041f5ee (diff)
downloadrails-35ee8fa3d8b3ad49179f86af2bec2e53af335ac9.tar.gz
rails-35ee8fa3d8b3ad49179f86af2bec2e53af335ac9.tar.bz2
rails-35ee8fa3d8b3ad49179f86af2bec2e53af335ac9.zip
Merge branch 'master' of github.com:lifo/docrails
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 06eebf79d9..cd596e37d2 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
@@ -153,6 +152,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
+ #
+ # Person.validators
+ # # => [
+ # # #<MyValidator:0x007fbff403e808 @options={}>,
+ # # #<OtherValidator:0x007fbff403d930 @options={:on=>:create}>,
+ # # #<StrictValidator:0x007fbff3204a30 @options={:strict=>true}>
+ # # ]
def validators
_validators.values.flatten.uniq
end
@@ -221,7 +235,6 @@ module ActiveModel
# @data[key]
# end
# end
- #
alias :read_attribute_for_validation :send
protected