EMail Validations--Multiple Regexes

Kaushik Tiwari
Sun, 25 Aug 2013 17:32:16 -0000

I am trying to use validates_format_of in my model file to validate an
email address. However, I need to enter two regexes for two special cases.
Basically, only a few top-level domain names are allowed.

However, it seems according to the source code for validates it only allows
one :format key and one set of options as the hash value. Is there a way to
use multiple regexes. I have tried the logical operators but it seems to
accept only the first one. Also, using two validates method on the same
field leads to nothing getting accepted as one violates the other condition.

So, I want to accept only certain top-level domain names, say google and
yahoo. How do I set up a validates method that does just that and rejects
all other emails.

Thanks

--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/0b02b468-461a-4cb8-8d12-8b7ad6340bdf%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.