sindresorhus / ow

Function argument validation for humans
https://sindresorhus.com/ow/
MIT License
3.8k stars 105 forks source link

Check if string is email address #155

Open derblitz opened 5 years ago

derblitz commented 5 years ago

What is the recommended way to check if a string is an email address?

sindresorhus commented 4 years ago

We intentionally left this out: https://github.com/sindresorhus/ow/pull/15#discussion_r147329494

It's very hard to do this correctly. The email grammar is extremely complex and ambiguous. Your best bet is to just do string.includes('@') and then validate that the email actually exists: https://www.google.com/search?q=validate+email&oq=validate+email&aqs=chrome..69i57j0l4j69i65.1686j0j1&sourceid=chrome&ie=UTF-8