3

I need to validate an Email address field comprehensively. From Wikipedia, I pulled the following valid/invalid email addresses, is there anything I am missing here? Thanks

Valid email addresses

Invalid email addresses

  • Abc.example.com (no @ character)
  • A@b@[email protected] (only one @ is allowed outside quotation marks)
  • a"b(c)d,e:f;gi[j\k][email protected] (none of the special characters in this local-part are allowed outside quotation marks)
  • just"not"[email protected] (quoted strings must be dot separated or the only element making up the local-part)
  • this is"not\[email protected] (spaces, quotes, and backslashes may only exist when within quoted strings and preceded by a backslash)
  • this\ still\"not\[email protected] (even if escaped (preceded by a backslash), spaces, quotes, and backslashes must still be contained by quotes)
  • 1234567890123456789012345678901234567890123456789012345678901234+x@example.com (too long)
  • [email protected] (double dot before @)
  • example@localhost (sent from localhost)
  • with caveat: Gmail lets this through, Email address#Local-part the dots altogether
  • [email protected] (double dot after @)
  • "much.more unusual"@example.com
  • a valid address with a leading space
  • a valid address with a trailing space
1
  • why is "example@localhost" invalid?
    – George
    Commented Jun 7, 2021 at 4:22

1 Answer 1

6

Yes, for the negative cases like this one:

a"b(c)d,e:f;gi[j\k][email protected] (none of the special characters in this local-part are allowed outside quotation marks)

You will need to split these up into one test per special character. Otherwise your test may pass because it finds a [ but could fail if only a ; were present. I.e. if the regex of your developer only finds some characters, you'll never know if you test them together.

Edit: another consideration. How will you test this validation: in the GUI? If so, reconsider your test level for this test... Testing a Regex extensively should be automated at unit test (or API) level. The actual inputs in the GUI should be limited just to see if the validation is triggered and displayed properly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.