plataformatec/devise — Issue #1618: Email validating regexp
Author: mensfeld
Created: 2012-02-02 14:00:35+00:00
State: open

Hello,
I use your Device.email_regexp to validate emails, however it is not fully working. Below example of your regexp and a different one:

device_mail_regexp = /\A[^@]+@([^@\.]+\.)+[^@\.]+\z/
diff_one = /^[A-Z0-9._%-]+@([A-Z0-9-]+\.)+[A-Z]{2,4}$/i

invalid_emails = %w{foobar@example.c @example.com f@com foo@bar..com foobar@example.infod foobar.example.com foo,@example.com foo@ex(ample.com test@Mss..a 'TEST>MMAA.PL}
invalid_emails.each do |mail|
puts "Device: #{mail.match(device_mail_regexp)}\n"
puts "Diff: #{mail.match(diff_one)}\n"
end

Would be great if You could change it so :with => Device.email_regexp would raise a proper message when it should