1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add a note to discourage users from using presence validators with allow_(nil|blank)

This commit is contained in:
Jeff Kreeftmeijer 2011-03-09 10:58:18 +01:00
parent 9798ee2619
commit e05e997907

View file

@ -463,9 +463,11 @@ h3. Common Validation Options
There are some common options that all the validation helpers can use. Here they are, except for the +:if+ and +:unless+ options, which are discussed later in "Conditional Validation":#conditional-validation.
TIP: Note that +allow_nil+ and +allow_blank+ will be ignored when using the presence validator. Please use the length validator if you want to validate if something is a specific length but allows for +nil+ values.
h4. +:allow_nil+
The +:allow_nil+ option skips the validation when the value being validated is +nil+. Using +:allow_nil+ with +validates_presence_of+ allows for +nil+, but any other +blank?+ value will still be rejected.
The +:allow_nil+ option skips the validation when the value being validated is +nil+.
<ruby>
class Coffee < ActiveRecord::Base