EMail Validations--Multiple Regexes

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.


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