L
laredotornado
Hi,
In my user model, I'm want to validate a field only if the field is
not empty. So I'm trying
validates_format_of :work_phone, :with => %r{^(\+\d)*\s*(\(\d{3}\)\s*)*
\d{3}(-{0,1}|\s{0,1})\d{2}(-{0,1}|\s{0,1})\d{2}$}, :allow_nil => true
but if my field, work_phone, is empty, I get the error that the format
is not valid. What is wrong with the above? - Dave
In my user model, I'm want to validate a field only if the field is
not empty. So I'm trying
validates_format_of :work_phone, :with => %r{^(\+\d)*\s*(\(\d{3}\)\s*)*
\d{3}(-{0,1}|\s{0,1})\d{2}(-{0,1}|\s{0,1})\d{2}$}, :allow_nil => true
but if my field, work_phone, is empty, I get the error that the format
is not valid. What is wrong with the above? - Dave