I wrote method to detect if the hostname inside :email exists in an array of blacklisted hostname’s to no avail I have the method almost working but can’t figure it out:
host = email.split("@").last // e.g. "hotmail.com"
bad_hostnames = %w(rtrtr.com )
if /.*(#{bad_hostnames.join("|")}).*\@/.match(host)
errors.add(:email, "Invalid temp mail provider")
end
What am I missing here? The regex is hard to test. Seems that the dot is causing issues, a similar method to check for certain blacklisted words in emails is working fine.
I believe you are looking for this code:
or this one: