Skip to content
This repository
Browse code

Add documentation for validate options

  • Loading branch information...
commit 26353b993b3bfb52d6c4adb92b6aa08d9712fd06 1 parent b2ccae4
Oscar Del Ben authored April 26, 2012
13  activemodel/lib/active_model/validations.rb
@@ -128,6 +128,19 @@ def validates_each(*attr_names, &block)
128 128
       #     end
129 129
       #   end
130 130
       #
  131
+      # Options:
  132
+      # * <tt>:on</tt> - Specifies the context where this validation is active
  133
+      #   (e.g. <tt>:on => :create</tt> or <tt>:on => :custom_validation_context</tt>)
  134
+      # * <tt>:allow_nil</tt> - Skip validation if attribute is +nil+.
  135
+      # * <tt>:allow_blank</tt> - Skip validation if attribute is blank.
  136
+      # * <tt>:if</tt> - Specifies a method, proc or string to call to determine
  137
+      #   if the validation should occur (e.g. <tt>:if => :allow_validation</tt>,
  138
+      #   or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The method,
  139
+      #   proc or string should return or evaluate to a true or false value.
  140
+      # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should
  141
+      #   not occur (e.g. <tt>:unless => :skip_validation</tt>, or
  142
+      #   <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The
  143
+      #   method, proc or string should return or evaluate to a true or false value.
131 144
       def validate(*args, &block)
132 145
         options = args.extract_options!
133 146
         if options.key?(:on)

0 notes on commit 26353b9

Please sign in to comment.
Something went wrong with that request. Please try again.