From 8d96b89110d2c16d395ec3a5dc13e33be76b8e78 Mon Sep 17 00:00:00 2001 From: Peer Allan Date: Fri, 18 Feb 2011 20:51:56 -0600 Subject: Clarification of ActiveRecord ActiveModel validation documentation --- activemodel/lib/active_model/validations.rb | 4 ++-- activemodel/lib/active_model/validations/acceptance.rb | 2 +- activemodel/lib/active_model/validations/confirmation.rb | 2 +- activemodel/lib/active_model/validations/format.rb | 2 +- activemodel/lib/active_model/validations/length.rb | 2 +- activemodel/lib/active_model/validations/numericality.rb | 2 +- activemodel/lib/active_model/validations/presence.rb | 3 +-- 7 files changed, 8 insertions(+), 9 deletions(-) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb index efd071fedc..5e2c7b411d 100644 --- a/activemodel/lib/active_model/validations.rb +++ b/activemodel/lib/active_model/validations.rb @@ -71,8 +71,8 @@ module ActiveModel # end # # Options: - # * :on - Specifies when this validation is active (default is - # :save, other options :create, :update). + # * :on - Specifies the context where this validation is active + # (e.g. :on => :create or :on => :special_rules) # * :allow_nil - Skip validation if attribute is +nil+. # * :allow_blank - Skip validation if attribute is blank. # * :if - Specifies a method, proc or string to call to determine diff --git a/activemodel/lib/active_model/validations/acceptance.rb b/activemodel/lib/active_model/validations/acceptance.rb index a7296d8e1d..fba44defc1 100644 --- a/activemodel/lib/active_model/validations/acceptance.rb +++ b/activemodel/lib/active_model/validations/acceptance.rb @@ -38,7 +38,7 @@ module ActiveModel # * :message - A custom error message (default is: "must be # accepted"). # * :on - Specifies when this validation is active (default is - # :save, other options are :create and + # nil, other options are :create and # :update). # * :allow_nil - Skip validation if attribute is +nil+ (default # is true). diff --git a/activemodel/lib/active_model/validations/confirmation.rb b/activemodel/lib/active_model/validations/confirmation.rb index 00df10cef0..bcefc7d888 100644 --- a/activemodel/lib/active_model/validations/confirmation.rb +++ b/activemodel/lib/active_model/validations/confirmation.rb @@ -46,7 +46,7 @@ module ActiveModel # * :message - A custom error message (default is: "doesn't match # confirmation"). # * :on - Specifies when this validation is active (default is - # :save, other options :create, :update). + # :nil, other options :create, :update). # * :if - Specifies a method, proc or string to call to determine # if the validation should occur (e.g. :if => :allow_validation, # or :if => Proc.new { |user| user.signup_step > 2 }). The diff --git a/activemodel/lib/active_model/validations/format.rb b/activemodel/lib/active_model/validations/format.rb index 104f403492..ca8920bce6 100644 --- a/activemodel/lib/active_model/validations/format.rb +++ b/activemodel/lib/active_model/validations/format.rb @@ -51,7 +51,7 @@ module ActiveModel # * :allow_blank - If set to true, skips this validation if the attribute is blank (default is +false+). # * :with - Regular expression that if the attribute matches will result in a successful validation. # * :without - Regular expression that if the attribute does not match will result in a successful validation. - # * :on - Specifies when this validation is active (default is :save, other options :create, :update). + # * :on - Specifies when this validation is active (default is nil, other options :create, :update). # * :if - Specifies a method, proc or string to call to determine if the validation should # occur (e.g. :if => :allow_validation, or :if => Proc.new { |user| user.signup_step > 2 }). The # method, proc or string should return or evaluate to a true or false value. diff --git a/activemodel/lib/active_model/validations/length.rb b/activemodel/lib/active_model/validations/length.rb index 5a46ecb4ac..97a5cb012e 100644 --- a/activemodel/lib/active_model/validations/length.rb +++ b/activemodel/lib/active_model/validations/length.rb @@ -83,7 +83,7 @@ module ActiveModel # * :too_short - The error message if the attribute goes under the minimum (default is: "is too short (min is %{count} characters)"). # * :wrong_length - The error message if using the :is method and the attribute is the wrong size (default is: "is the wrong length (should be %{count} characters)"). # * :message - The error message to use for a :minimum, :maximum, or :is violation. An alias of the appropriate too_long/too_short/wrong_length message. - # * :on - Specifies when this validation is active (default is :save, other options :create, :update). + # * :on - Specifies the context where this validation is active (e.g. :on => :create or :on => :special_rules) # * :if - Specifies a method, proc or string to call to determine if the validation should # occur (e.g. :if => :allow_validation, or :if => Proc.new { |user| user.signup_step > 2 }). The # method, proc or string should return or evaluate to a true or false value. diff --git a/activemodel/lib/active_model/validations/numericality.rb b/activemodel/lib/active_model/validations/numericality.rb index 95fe20de75..7b155bb7f7 100644 --- a/activemodel/lib/active_model/validations/numericality.rb +++ b/activemodel/lib/active_model/validations/numericality.rb @@ -93,7 +93,7 @@ module ActiveModel # # Configuration options: # * :message - A custom error message (default is: "is not a number"). - # * :on - Specifies when this validation is active (default is :save, other options :create, :update). + # * :on - Specifies the context where this validation is active (e.g. :on => :create or :on => :special_rules) # * :only_integer - Specifies whether the value has to be an integer, e.g. an integral value (default is +false+). # * :allow_nil - Skip validation if attribute is +nil+ (default is +false+). Notice that for fixnum and float columns empty strings are converted to +nil+. # * :greater_than - Specifies the value must be greater than the supplied value. diff --git a/activemodel/lib/active_model/validations/presence.rb b/activemodel/lib/active_model/validations/presence.rb index 28c4640b17..3bfd6f15d1 100644 --- a/activemodel/lib/active_model/validations/presence.rb +++ b/activemodel/lib/active_model/validations/presence.rb @@ -26,8 +26,7 @@ module ActiveModel # # Configuration options: # * message - A custom error message (default is: "can't be blank"). - # * on - Specifies when this validation is active (default is :save, other options :create, - # :update). + # * :on - Specifies the context where this validation is active (e.g. :on => :create or :on => :special_rules) # * if - Specifies a method, proc or string to call to determine if the validation should # occur (e.g. :if => :allow_validation, or :if => Proc.new { |user| user.signup_step > 2 }). # The method, proc or string should return or evaluate to a true or false value. -- cgit v1.2.3