5 ms·
Here's a secret: regex: /^(.+)\@(.+)\.(.+)$/ maxlen: 254, minlen:5 Aside from sending your verification email, that's all you need.
by fein 14y ago
Here's a secret:
regex: /^(.+)\@(.+)\.(.+)$/
maxlen: 254, minlen:5
Aside from sending your verification email, that's all you need.
- ceejayoz 14y agohttp://www.ex-parrot.com/pdw/Mail-RFC822-Address.html http://www.ex-parrot.com/pdw/Mail-RFC822-Address.html
- saurik 14y agohttps://news.ycombinator.com/item?id=4794368 https://news.ycombinator.com/item?id=4794368
- pythonist 14y agoI believe that this part is using the Django's pattern matching: super(EmailValidator, self).__call__(value) Just tried it. It works!
- micampe 14y agoAre single letter domain and tlds allowed?
- fein 14y agoyep, thats why we do a check for a min of 5 chars: a@a.a edit: the regex should pick this up by default anyway, given its looking for .+ and not .*, but my validation libs have the min and max length built in as well.
- micampe 14y agoI meant to ask if they are valid in the IETF sense, not in your regex. Turns out that single letter second level domains are allowed but they are reserved in some TLDs http://en.wikipedia.org/wiki/Single-letter_second-level_domain http://en.wikipedia.org/wiki/Single-letter_second-level_doma... On the other hand, no single letter TLD exists http://data.iana.org/TLD/tlds-alpha-by-domain.txt http://data.iana.org/TLD/tlds-alpha-by-domain.txt And I also just found out in that list that there are IDN TLDs (see punycode toward the end of the list), I didn’t know that. Full decoded list: http://mct.verisign-grs.com/convertServlet?input=XN--0ZWM56D%0D%0AXN--11B5BS3A9AJ6G%0D%0AXN--3E0B707E%0D%0AXN--45BRJ9C%0D%0AXN--80AKHBYKNJ4F%0D%0AXN--80AO21A%0D%0AXN--90A3AC%0D%0AXN--9T4B11YI5A%0D%0AXN--CLCHC0EA0B2G2A9GCD%0D%0AXN--DEBA0AD%0D%0AXN--FIQS8S%0D%0AXN--FIQZ9S%0D%0AXN--FPCRJ9C3D%0D%0AXN--FZC2C9E2C%0D%0AXN--G6W251D%0D%0AXN--GECRJ9C%0D%0AXN--H2BRJ9C%0D%0AXN--HGBK6AJ7F53BBA%0D%0AXN--HLCJ6AYA9ESC7A%0D%0AXN--J6W193G%0D%0AXN--JXALPDLP%0D%0AXN--KGBECHTV%0D%0AXN--KPRW13D%0D%0AXN--KPRY57D%0D%0AXN--LGBBAT1AD8J%0D%0AXN--MGB9AWBF%0D%0AXN--MGBAAM7A8H%0D%0AXN--MGBAYH7GPA%0D%0AXN--MGBBH1A71E%0D%0AXN--MGBC0A9AZCG%0D%0AXN--MGBERP4A5D4AR%0D%0AXN--MGBX4CD0AB%0D%0AXN--O3CW4H%0D%0AXN--OGBPF8FL%0D%0AXN--P1AI%0D%0AXN--PGBS0DH%0D%0AXN--S9BRJ9C%0D%0AXN--WGBH1C%0D%0AXN--WGBL6A%0D%0AXN--XKC2AL3HYE2A%0D%0AXN--XKC2DL3A5EE0H%0D%0AXN--YFRO4I67O%0D%0AXN--YGBI2AMMX%0D%0AXN--ZCKZAH http://mct.verisign-grs.com/convertServlet?input=XN--0ZWM56D... I wonder how many validators fail on these.
- noneTheHacker 14y agoThat excludes TLD emails like postbox@com I have never come across someone using one but it is valid. I would actually hate to see someone try to use one. I come across enough issues trying to use '+' in my gmail email address. http://en.wikipedia.org/wiki/Email_address#Valid_email_addresses http://en.wikipedia.org/wiki/Email_address#Valid_email_addre...
- nicktelford 14y agoIt's not just TLDs. Machine aliases are also perfectly valid in e-mail addresses, e.g. "root@localhost", "fred@finance" etc. This might not be practical in a majority of applications (you're hardly going to sign up to 3rd party services using an alias to a machine on your local network) but if you're building a generic e-mail address validation library, it's an edge case you cannot ignore.
- Sephr 14y agon@ai (Ian Goldberg's real, valid email address) is rejected by this by your minlength and by the subdomain requirement. You're better off just checking for an @ and leaving the rest to your smtp library.
- threedaymonk 14y agoI just check for /.@./, which catches obvious errors like leaving out the email, or typing something in the wrong field. Beyond that, there's no point making assumptions (like "all domains have a dot").
- astrodust 14y agoToday all domains have at least one dot in them. If, at some point in the future, you're allowed to have "jimmy@nike", directly at a TLD, we'll have bigger fish to fry than that.
- baudehlo 14y agoNo they don't. http://serverfault.com/questions/154991/why-do-some-tld-have-an-mx-record-on-the-zone-root-e-g-ai http://serverfault.com/questions/154991/why-do-some-tld-have...
- astrodust 14y agoEdge case city, there are perhaps a handful of people in the world without a dot in their domain, but yes, technically correct. The thing is, for every legitimate bob@ai there are millions of erroneous bob@gmail mistakes that would slip through. At the very least a warning should be presented.