validates_format_of / nil

Validations provide mechanisms to do what you’re asking. See the API on validations for more info.

Possible solutions can be found via google “validates_format_of nil”

http://significantbits.wordpress.com/2007/03/02/apply-rails-validation-rules-only-when-the-attribute-is-not-nil/

http://brighter.net/2007/6/23/validates_format_of-something-without-validates_presence_of

Good luck!

:allow_nil works for most of the validates_ calls, but it is not an option of validates_format_of

Mason Kessinger wrote: