Michael Long, you’re right that this validation system rejects some valid emails. But at the same time, Swift is mostly used for iOS development, and email validation is used for authentication (which I mentioned in the article). I clearly wouldn’t like my users to register with email having ip address after @ .

My own email has dash inside, and several times it was rejected because of it. The regular expression I posted is result of real life test, I used it in several projects with hundreds of thousands users (in total). I didn’t get a single support request related to email validation.

At the same time, I mentioned that some valid emails may be recognized as invalid, for example, user@localhost (example from the article). But these emails I wouldn’t like to see among my users. And I think it’s still better than sending invalid email to API. But it’s my personal opinion.

Game and software developer with more than 15 years experience. Founder and CEO at Mariposa Studios, freelancer.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store