Skip to content

Commit

Permalink
copy-edits 8d96b89
Browse files Browse the repository at this point in the history
  • Loading branch information
fxn authored and bowsersenior committed Feb 21, 2011
1 parent 5e69deb commit 0d41fa9
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 19 deletions.
4 changes: 2 additions & 2 deletions activemodel/lib/active_model/validations.rb
Expand Up @@ -71,8 +71,8 @@ module ClassMethods
# end
#
# Options:
# * <tt>:on</tt> - Specifies the context where this validation is active
# (e.g. <tt>:on => :create</tt> or <tt>:on => :special_rules</tt>)
# * <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
Expand Down
6 changes: 3 additions & 3 deletions activemodel/lib/active_model/validations/acceptance.rb
Expand Up @@ -37,9 +37,9 @@ module HelperMethods
# Configuration options:
# * <tt>:message</tt> - A custom error message (default is: "must be
# accepted").
# * <tt>:on</tt> - Specifies when this validation is active (default is
# <tt>nil</tt>, other options are <tt>:create</tt> and
# <tt>:update</tt>).
# * <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>:allow_nil</tt> - Skip validation if attribute is +nil+ (default
# is true).
# * <tt>:accept</tt> - Specifies value that is considered accepted.
Expand Down
5 changes: 3 additions & 2 deletions activemodel/lib/active_model/validations/confirmation.rb
Expand Up @@ -45,8 +45,9 @@ module HelperMethods
# Configuration options:
# * <tt>:message</tt> - A custom error message (default is: "doesn't match
# confirmation").
# * <tt>:on</tt> - Specifies when this validation is active (default is
# <tt>:nil</tt>, other options <tt>:create</tt>, <tt>:update</tt>).
# * <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>: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
Expand Down
3 changes: 3 additions & 0 deletions activemodel/lib/active_model/validations/exclusion.rb
Expand Up @@ -29,6 +29,9 @@ module HelperMethods
# * <tt>:message</tt> - Specifies a custom error message (default is: "is reserved").
# * <tt>:allow_nil</tt> - If set to true, skips this validation if the attribute is +nil+ (default is +false+).
# * <tt>:allow_blank</tt> - If set to true, skips this validation if the attribute is blank (default is +false+).
# * <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>: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.
Expand Down
4 changes: 3 additions & 1 deletion activemodel/lib/active_model/validations/format.rb
Expand Up @@ -51,7 +51,9 @@ module HelperMethods
# * <tt>:allow_blank</tt> - If set to true, skips this validation if the attribute is blank (default is +false+).
# * <tt>:with</tt> - Regular expression that if the attribute matches will result in a successful validation.
# * <tt>:without</tt> - Regular expression that if the attribute does not match will result in a successful validation.
# * <tt>:on</tt> - Specifies when this validation is active (default is <tt>nil</tt>, other options <tt>:create</tt>, <tt>:update</tt>).
# * <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>: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.
Expand Down
3 changes: 3 additions & 0 deletions activemodel/lib/active_model/validations/inclusion.rb
Expand Up @@ -38,6 +38,9 @@ module HelperMethods
# * <tt>:message</tt> - Specifies a custom error message (default is: "is not included in the list").
# * <tt>:allow_nil</tt> - If set to true, skips this validation if the attribute is +nil+ (default is +false+).
# * <tt>:allow_blank</tt> - If set to true, skips this validation if the attribute is blank (default is +false+).
# * <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>: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.
Expand Down
4 changes: 3 additions & 1 deletion activemodel/lib/active_model/validations/length.rb
Expand Up @@ -83,7 +83,9 @@ module HelperMethods
# * <tt>:too_short</tt> - The error message if the attribute goes under the minimum (default is: "is too short (min is %{count} characters)").
# * <tt>:wrong_length</tt> - The error message if using the <tt>:is</tt> method and the attribute is the wrong size (default is: "is the wrong length (should be %{count} characters)").
# * <tt>:message</tt> - The error message to use for a <tt>:minimum</tt>, <tt>:maximum</tt>, or <tt>:is</tt> violation. An alias of the appropriate <tt>too_long</tt>/<tt>too_short</tt>/<tt>wrong_length</tt> message.
# * <tt>:on</tt> - Specifies the context where this validation is active (e.g. <tt>:on => :create</tt> or <tt>:on => :special_rules</tt>)
# * <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>: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.
Expand Down
4 changes: 3 additions & 1 deletion activemodel/lib/active_model/validations/numericality.rb
Expand Up @@ -93,7 +93,9 @@ module HelperMethods
#
# Configuration options:
# * <tt>:message</tt> - A custom error message (default is: "is not a number").
# * <tt>:on</tt> - Specifies the context where this validation is active (e.g. <tt>:on => :create</tt> or <tt>:on => :special_rules</tt>)
# * <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>:only_integer</tt> - Specifies whether the value has to be an integer, e.g. an integral value (default is +false+).
# * <tt>:allow_nil</tt> - Skip validation if attribute is +nil+ (default is +false+). Notice that for fixnum and float columns empty strings are converted to +nil+.
# * <tt>:greater_than</tt> - Specifies the value must be greater than the supplied value.
Expand Down
4 changes: 3 additions & 1 deletion activemodel/lib/active_model/validations/presence.rb
Expand Up @@ -26,7 +26,9 @@ module HelperMethods
#
# Configuration options:
# * <tt>message</tt> - A custom error message (default is: "can't be blank").
# * <tt>:on</tt> - Specifies the context where this validation is active (e.g. <tt>:on => :create</tt> or <tt>:on => :special_rules</tt>)
# * <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>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.
Expand Down
14 changes: 7 additions & 7 deletions activerecord/lib/active_record/validations.rb
Expand Up @@ -20,7 +20,7 @@ def initialize(record)

# = Active Record Validations
#
# Active Record includes the majority of its validations from ActiveModel::Validations
# Active Record includes the majority of its validations from <tt>ActiveModel::Validations</tt>
# all of which accept the <tt>:on</tt> argument to define the context where the
# validations are active. Active Record will always supply either the context of
# <tt>:create</tt> or <tt>:update</tt> dependent on whether the model is a
Expand Down Expand Up @@ -56,14 +56,14 @@ def save!(options={})
perform_validations(options) ? super : raise(RecordInvalid.new(self))
end

# Runs all the specified validations and returns true if no errors were added otherwise false.
# Runs all the validations within the specified context. Returns true if no errors are found,
# false otherwise.
#
# ==== Arguments
# If the argument is false (default is +nil+), the context is set to <tt>:create</tt> if
# <tt>new_record?</tt> is true, and to <tt>:update</tt> if it is not.
#
# * <tt>context</tt> - Context to scope the execution of the validations. Default is <tt>nil</tt>.
# If <tt>nil</tt> then the response of <tt>new_record?</tt> will determine the context. If <tt>new_record?</tt>
# returns true the context will be <tt>:create</tt>, otherwise <tt>:update</tt>. Validation contexts
# for each validation can be defined using the <tt>:on</tt> option
# Validations with no <tt>:on</tt> option will run no matter the context. Validations with
# some <tt>:on</tt> option will only run in the specified context.
def valid?(context = nil)
context ||= (new_record? ? :create : :update)
output = super(context)
Expand Down
4 changes: 3 additions & 1 deletion activerecord/lib/active_record/validations/associated.rb
Expand Up @@ -33,7 +33,9 @@ module ClassMethods
#
# Configuration options:
# * <tt>:message</tt> - A custom error message (default is: "is invalid")
# * <tt>:on</tt> - Specifies when this validation is active (default is <tt>nil</tt>, other options <tt>:create</tt>, <tt>:update</tt>).
# * <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>: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.
Expand Down

0 comments on commit 0d41fa9

Please sign in to comment.