Re: EMail Validations--Multiple Regexes

Colin Law
Tue, 27 Aug 2013 08:23:27 -0000

On 25 August 2013 18:32, Kaushik Tiwari
<kaushik.tewari-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> 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.

Just extend the regex to include both cases.  For example abc|def|xyz
matches abc, def or xyz.

Colin

--
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/CAL%3D0gLvjQ52Xp_qi8g63iTePKj0sOS8D-kbKOukeekiGx1fuOA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.