I would like to have a list of email domains that are validated against to prevent from registering on my app.
10minutemail.com, yopmail.com, mail.com, mail.ru etc...
I have a list of domains in my user model like so:
BAD_DOMAINS = [/10minutemail.com/, /yopmail.com/, /mail/
I would like to add a User validates on the email field to add an error if the user is registering with one of these domains.
BAD_DOMAINS.each { |rule| return true if !domain.match(rule).nil? }
I have that regex working, but how do I add that as a validates? I tried this:
validates :email, :format => { : exclusion => BAD_DOMAINS,
:message => "%{value} no good." }
Thanks