开发者

Email validation with specific domains in Rails 3

开发者 https://www.devze.com 2023-02-19 23:28 出处:网络
What is the best way开发者_如何学JAVA to exlude certain email addresses (in the validation) in Rails3? I want to exclude domains like \"hotmail.com, live.com and gmail.com\".

What is the best way开发者_如何学JAVA to exlude certain email addresses (in the validation) in Rails3? I want to exclude domains like "hotmail.com, live.com and gmail.com".

Thanks


Maybe u can get some ideas from here: Rails 3 - Help with a Email Validation Regex It doesnt give a working solution thou..


begin
  Mail::Address.new(email)
  #valid
rescue Mail::Field::ParseError => e
  #invalid
end
0

精彩评论

暂无评论...
验证码 换一张
取 消