Stop Validating Email Addresses with Regex (2012)
101–110 of 228 posts
Re: Stop Validating Email Addresses with Regex (2012)
#102I appreciate the idea here but generally you set a non perfect regex expression and just roll on with whatever other verification there is (send email). Well I don’t but if you did I don’t see much harm. I won’t ask people to type the email twice, that’s just annoying.
And it becomes super annoying when you can't paste into the second field. Had to implement this once - should have rage quit immediately.
Re: Stop Validating Email Addresses with Regex (2012)
#103Re: Stop Validating Email Addresses with Regex (2012)
#104Re: Stop Validating Email Addresses with Regex (2012)
#105There is not reason whatsoever to validate to a standard just because it's a standard. Validate to what you will support.
Re: Stop Validating Email Addresses with Regex (2012)
#106https://www.youtube.com/watch?v=xxX81WmXjPg
It's more a joke than edifying, but it was very fun for me (and, I think, the audience), and illustrates the difficulty of email validation well.
Re: Stop Validating Email Addresses with Regex (2012)
#107This won't be popular, but: 1. An experienced dev just killed 54k stars on GitHub due to pressing a button in an auto-pilot mode. Do you think a Joe High who wants to give you $100 won't ever type '2' instead of '@'? What about an old lady? Or someone with physical difficulties? Have you personally ever made a typo in an email? 2. That code in the article is not color highlighted (rainbowed for Regex) or formatted pr…
I won't bet my life on it but probably some other sucker will have to fix it. This happened to me where I found a regex that was validating urls was incorrect after urls were allowed to contain unicode stuff (I do not remember the details just that we had an url from a customer that contained arabic looking characters)
IMO the language standard library should include this stuff of validating stuff to avoid developers copy pasting dubious quality regex from Stack Overflow
Re: Stop Validating Email Addresses with Regex (2012)
#108Validate emails in a manner that is representative of the typical use of your service. If it’s a specialist email processing tool, then you should probably follow an RFC. If it’s a dating app, you can probably just use a regex that covers common cases to help users avoid typos. I think the decision is similar to the one picking how modern are the browsers you are going to support. It’s a trade-off. That’s my take on…
You will want to check ownership by sending a verification email anyway. If you want to avoid typos, show a "are you sure... yes/no" warning, there is no need to block anybody. Typos will overwhelmingly lead to valid-looking addresses anyway.
I needed to do just that once - I was given a flat file with some bulk export data that came from some other system that I had no exposure to and needed to clean up contact data by figuring out what was what, separating names from phone numbers, from postal addresses, from emails, etc. It just needed some rate of success, not to be perfect.
Lets not assume that we always know what people are trying to do and what is the best way to do it. Devil is in the details.
Re: Stop Validating Email Addresses with Regex (2012)
#109Does anyone on HN have any of these "surprising" email addresses that most people and developers do not expect? How does it work with common e-mail clients? How do people react when you show/tell them your email? I have a domain that uses non-ascii characters, and while I can receive emails on that domain, hosted by Fastmail, Fastmail clients refuses to _send_ emails to that domain (I can, if I type the domain as Pun…
I do
> How does it work with common e-mail clients?
Perfectly
> How do people react when you show/tell them your email?
With confusion, so it requires some gentle insistence that I know my own email address.
Re: Stop Validating Email Addresses with Regex (2012)
#110RFCs for email addresses are cool, but on the web we have our own standards! https://html.spec.whatwg.org/multipage/input.html#valid-e-ma... "This requirement is a willful violation of RFC 5322, which defines a syntax for email addresses that is simultaneously too strict (before the "@" character), too vague (after the "@" character), and too lax (allowing comments, whitespace characters, and quoted strings in manner…
One of the biggest problems with email input is typos -- and there are some very common typos that could easily be accounted for with code. For example foo@gmail.co, foo@gmial.com, foo@comcast, etc.
It should be common, when these types of typos occur, to prompt the user to fix them. Unfortunately, this is quite rare.