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) john@learn.edu - valid
2) john@mypost.com - valid
3) john@gmail.com - invalid
4) john@dblist.org - invalid
I have tried to solve the problem using the below code in my user.rb
model file but to no avail.
if ('xc@dblist.com' =~ /\A[\w]([^@\s,;]+)@((mypost|[\w-]+\.)+(edu|com))\z/i) != nil
return true
else
return false
end