Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation failures #29

Open
johnrees opened this issue Dec 17, 2012 · 1 comment
Open

Validation failures #29

johnrees opened this issue Dec 17, 2012 · 1 comment

Comments

@johnrees
Copy link

I don't know how reliable the valid and invalid lists are on this wikipedia page

http://en.wikipedia.org/wiki/Email_address#Valid_email_addresses

but I have encountered a failing test for the following addresses -

should be invalid

should be valid

user@[IPv6:2001:db8:1ff::a0b:dbd0]
"much.more unusual"@example.com
"[email protected]"@example.com
"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com
postbox@com
"()<>[]:,;@\"!#$%&*+-/=?^_`{}| ~  ? ^_`{}|~.a"@example.org

spec/models/user.rb

# encoding: UTF-8
require 'spec_helper'
#...
describe User do
  it "should validate email format" do
    # http://en.wikipedia.org/wiki/Email_address#Valid_email_addresses
    invalid_emails = [
      'just"not"[email protected]'
    ]
    invalid_emails.each do |email|
      build(:user, email: email).should be_invalid
      build(:user, email: email).errors_on(:email).first.should match(/invalid/)
    end
    valid_emails = [
      'user@[IPv6:2001:db8:1ff::a0b:dbd0]',
      '"much.more unusual"@example.com',
      '"[email protected]"@example.com',
      '"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com',
      'postbox@com',
      '"()<>[]:,;@\"!#$%&*+-/=?^_`{}| ~  ? ^_`{}|~.a"@example.org'
    ]
    valid_emails.each do |email|
      build(:user, email: email).should be_valid
    end
  end
end
alexdunae added a commit that referenced this issue Aug 9, 2022
Allow joining multiple atoms, e.g.

[email protected]
aa."bb"@example.com
"aa"."bb"@example.com

See #29
alexdunae added a commit that referenced this issue Aug 9, 2022
Allow joining multiple atoms, e.g.

[email protected]
aa."bb"@example.com
"aa"."bb"@example.com

See #29
alexdunae added a commit that referenced this issue Aug 9, 2022
Allow joining multiple atoms, e.g.

[email protected]
aa."bb"@example.com
"aa"."bb"@example.com

See #29
@alexdunae
Copy link
Contributor

Here's a nice test suite with a pretty exhaustive set of email addresses, including the distinction between "public internet" and "strictly allowed" modes which seems useful... https://code.iamcal.com/php/rfc822/tests/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants