Tushar Gandhi wrote:
> Hi,
> I am trying to validate the email format by using "validates_format_of".
> I have written a code like this:-
> "validates_format_of :email,
> :with=>/^[0-9a-za-z_][\w\.-]*[a-za-z0-...@[a-za-z0-9][\w\.-]*[a-za-z0-9]\.[a-za-z][a-za-z\.]*[a-za-z]$/,
>                       :message => "is not valid" "
> 
> It is working fine, but in my application email id is not manadatory.
> So how should add the condition in this validator so that it will
> validate the email only when the email address is present.
> 
> Can anyone help me out?
> 
> Thanks,
> Tushar

Have you considered :unless
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to