ow icon indicating copy to clipboard operation
ow copied to clipboard

Check if string is email address

Open derblitz opened this issue 5 years ago • 1 comments

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

derblitz avatar Jul 30 '19 09:07 derblitz

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

sindresorhus avatar Nov 12 '19 08:11 sindresorhus