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://brighter.net/2007/6/23/validates_format_of-something-without-validates_presence_of
Good luck!