From 4bbd05c90e5a62c0316307b3ca7c2262ed98b567 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Thu, 17 May 2012 10:54:29 -0500 Subject: fix validations docs --- .../lib/active_model/validations/presence.rb | 29 ++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'activemodel/lib/active_model/validations/presence.rb') diff --git a/activemodel/lib/active_model/validations/presence.rb b/activemodel/lib/active_model/validations/presence.rb index 9a643a6f5c..efd1372a6b 100644 --- a/activemodel/lib/active_model/validations/presence.rb +++ b/activemodel/lib/active_model/validations/presence.rb @@ -1,7 +1,6 @@ require 'active_support/core_ext/object/blank' module ActiveModel - # == Active Model Presence Validator module Validations class PresenceValidator < EachValidator @@ -11,7 +10,8 @@ module ActiveModel end module HelperMethods - # Validates that the specified attributes are not blank (as defined by Object#blank?). Happens by default on save. Example: + # Validates that the specified attributes are not blank (as defined by + # Object#blank?). Happens by default on save. Example: # # class Person < ActiveRecord::Base # validates_presence_of :first_name @@ -19,25 +19,28 @@ module ActiveModel # # The first_name attribute must be in the object and it cannot be blank. # - # If you want to validate the presence of a boolean field (where the real values are true and false), - # you will want to use validates_inclusion_of :field_name, :in => [true, false]. + # If you want to validate the presence of a boolean field (where the real values + # are true and false), you will want to use validates_inclusion_of :field_name, + # :in => [true, false]. # - # This is due to the way Object#blank? handles boolean values: false.blank? # => true. + # This is due to the way Object#blank? handles boolean values: + # false.blank? # => true. # # Configuration options: # * :message - A custom error message (default is: "can't be blank"). # * :on - Specifies when this validation is active. Runs in all # validation contexts by default (+nil+), other options are :create # and :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. - # * :unless - Specifies a method, proc or string to call to determine if the validation should - # not occur (e.g. :unless => :skip_validation, or :unless => Proc.new { |user| user.signup_step <= 2 }). - # The method, proc or string should return or evaluate to a true or false value. + # * :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. + # * :unless - Specifies a method, proc or string to call to determine + # if the validation should not occur (e.g. :unless => :skip_validation, + # or :unless => Proc.new { |user| user.signup_step <= 2 }). The method, + # proc or string should return or evaluate to a true or false value. # * :strict - Specifies whether validation should be strict. - # See ActiveModel::Validation#validates! for more information - # + # See ActiveModel::Validation#validates! for more information. def validates_presence_of(*attr_names) validates_with PresenceValidator, _merge_attributes(attr_names) end -- cgit v1.2.3