Email address validation of Top Level Domain

riship89 picture riship89 · Mar 21, 2013 · Viewed 7.8k times · Source

Our QA has filed a bug that says top level domain of the email address cannot be of one character.

[email protected]

I am having a hard time looking into standards. Can somebody confirm if setting top level domain minimum length is a right thing to do?

Answer

Dai picture Dai · Mar 21, 2013

The rules for validating email addresses are as complicated as they are likely to be buggy in their implementation.

Rather than validating an email address, consider verifying it directly instead: http://davidcel.is/blog/2012/09/06/stop-validating-email-addresses-with-regex/

The problem with your case, is that there is a very real possibility that ICANN might introduce single-letter top-level domain names, and individual DNS labels can be of length 1, in fact "bar.z" is a valid email address domain name if sent from within a DNS tree/organization where that exists as a sub-domain (i.e. if the mailserver is smtp.mycompany.org and I've also defined an MX server for bar.z.mycompany.org).