diff options
author | Zachary Scott <e@zzak.io> | 2014-10-03 17:29:25 -0700 |
---|---|---|
committer | Zachary Scott <e@zzak.io> | 2014-10-03 17:29:25 -0700 |
commit | 44e6d91a07c26cfd7d7b5360cc9a8184b0692859 (patch) | |
tree | 64a011d3f71d422579afb3d1179577a95eb45fba /activemodel/lib/active_model/validations | |
parent | cad635995ca945d4137d0aab64d46313aee4f556 (diff) | |
parent | 2bb0abbec0e4abe843131f188129a1189b1bf714 (diff) | |
download | rails-44e6d91a07c26cfd7d7b5360cc9a8184b0692859.tar.gz rails-44e6d91a07c26cfd7d7b5360cc9a8184b0692859.tar.bz2 rails-44e6d91a07c26cfd7d7b5360cc9a8184b0692859.zip |
Merge pull request #16409 from justinweiss/update_validation_context_documentation
Docs: Add a note on custom validation contexts. [ci skip]
Diffstat (limited to 'activemodel/lib/active_model/validations')
-rw-r--r-- | activemodel/lib/active_model/validations/validates.rb | 8 | ||||
-rw-r--r-- | activemodel/lib/active_model/validations/with.rb | 7 |
2 files changed, 10 insertions, 5 deletions
diff --git a/activemodel/lib/active_model/validations/validates.rb b/activemodel/lib/active_model/validations/validates.rb index ae8d377fdf..bda436d8d0 100644 --- a/activemodel/lib/active_model/validations/validates.rb +++ b/activemodel/lib/active_model/validations/validates.rb @@ -71,9 +71,11 @@ module ActiveModel # # There is also a list of options that could be used along with validators: # - # * <tt>:on</tt> - Specifies when this validation is active. Runs in all - # validation contexts by default (+nil+), other options are <tt>:create</tt> - # and <tt>:update</tt>. + # * <tt>:on</tt> - Specifies the contexts where this validation is active. + # Runs in all validation contexts by default (nil). You can pass a symbol + # or an array of symbols. (e.g. <tt>on: :create</tt> or + # <tt>on: :custom_validation_context</tt> or + # <tt>on: [:create, :custom_validation_context]</tt>) # * <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, diff --git a/activemodel/lib/active_model/validations/with.rb b/activemodel/lib/active_model/validations/with.rb index ff41572105..a2531327bf 100644 --- a/activemodel/lib/active_model/validations/with.rb +++ b/activemodel/lib/active_model/validations/with.rb @@ -52,8 +52,11 @@ module ActiveModel # end # # Configuration options: - # * <tt>:on</tt> - Specifies when this validation is active - # (<tt>:create</tt> or <tt>:update</tt>). + # * <tt>:on</tt> - Specifies the contexts where this validation is active. + # Runs in all validation contexts by default (nil). You can pass a symbol + # or an array of symbols. (e.g. <tt>on: :create</tt> or + # <tt>on: :custom_validation_context</tt> or + # <tt>on: [:create, :custom_validation_context]</tt>) # * <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>). |