I want to validate email address with a particular suffix which should be like email. It must have .edu
or must have @mypost.com
. As an example, I have four email addresses as shown below:
1) [email protected] - valid
2) [email protected] - valid
3) [email protected] - invalid
4) [email protected] - invalid
I have tried to solve the problem using the below code in my user.rb
model file but to no avail.
if ('[email protected]' =~ /\A[\w]([^@\s,;]+)@((mypost|[\w-]+\.)+(edu|com))\z/i) != nil
return true
else
return false
end