aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model
diff options
context:
space:
mode:
authorOscar Del Ben <info@oscardelben.com>2012-04-26 10:09:12 +0200
committerOscar Del Ben <info@oscardelben.com>2012-04-26 10:09:12 +0200
commit26353b993b3bfb52d6c4adb92b6aa08d9712fd06 (patch)
tree89d1200e743e58fa362dc739ec433da2e344b795 /activemodel/lib/active_model
parentb2ccae466e12659df97969661dae389ac0eb6e2c (diff)
downloadrails-26353b993b3bfb52d6c4adb92b6aa08d9712fd06.tar.gz
rails-26353b993b3bfb52d6c4adb92b6aa08d9712fd06.tar.bz2
rails-26353b993b3bfb52d6c4adb92b6aa08d9712fd06.zip
Add documentation for validate options
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r--activemodel/lib/active_model/validations.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb
index ebb0dbb1ca..b5e9d7514a 100644
--- a/activemodel/lib/active_model/validations.rb
+++ b/activemodel/lib/active_model/validations.rb
@@ -128,6 +128,19 @@ module ActiveModel
# end
# end
#
+ # Options:
+ # * <tt>:on</tt> - Specifies the context where this validation is active
+ # (e.g. <tt>:on => :create</tt> or <tt>:on => :custom_validation_context</tt>)
+ # * <tt>:allow_nil</tt> - Skip validation if attribute is +nil+.
+ # * <tt>:allow_blank</tt> - Skip validation if attribute is blank.
+ # * <tt>:if</tt> - Specifies a method, proc or string to call to determine
+ # if the validation should occur (e.g. <tt>:if => :allow_validation</tt>,
+ # or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The method,
+ # proc or string should return or evaluate to a true or false value.
+ # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should
+ # not occur (e.g. <tt>:unless => :skip_validation</tt>, or
+ # <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The
+ # method, proc or string should return or evaluate to a true or false value.
def validate(*args, &block)
options = args.extract_options!
if options.key?(:on)