5 ms·
As far as I know, that literally is the only way to validate an email address, universally speaking, beyond an internal whitespace check. But I think if you ta
by geoelectric 6y ago
As far as I know, that literally is the only way to validate an email address, universally speaking, beyond an internal whitespace check.
But I think if you take "local" out of the equation, as you would for customer emails, you can validate a bit more. You might be able to validate on a single @ being in there somewhere, with something before and after it, maybe look for a period after the @ for "addr@domain.tld" as I think every external address needs a dotted domain.
That's about as far as I think you can safely go. Anything else is legal.
- arp242 6y agoDomains labels are fairly strictly defined, so you check that a bit more stringently. > as I think every external address needs a dotted domain. Something like example@com is technically a valid email address; although I don't know if there are any TLDs which accept emails.
- geoelectric 6y agoThat's true, I didn't think about that case. I don't think I've ever seen a bare TLD in real life like that though--maybe very early on as DNS became a thing? Not since the web though.
- sohex 6y agoWell, maybe not a single @. At least one @ maybe. There's a set of special characters that aren't permitted in the local part of an email address including @... unless they're quoted. So "@"@example.com is a valid address.
- geoelectric 6y agoOof, thanks. I forgot you could quote the @ and thought it was the one universally illegal character. Also forgot there were others, oops. I usually just recommend people don't validate email addys and let the email verification message do the job for you. This is pretty much why.