email-address-util

1.0.0 • Public • Published

email-address-util

Utilities for working with email addresses

Usage

# Install the package 
npm install email-address-util
# Require it in your JS file
const EmailUtil = require("email-address-util");

Validate

Validate that the given string is a valid email address. This method uses the regular expression from W3, then validates the domain against IANA's list of valid TLDs.

EmailUtil.validate("valid@example.com")    # => true
EmailUtil.validate("in(valid@example.com") # => false

Extract

Extract the first email address found in the given string. Uses the same regular expression as validate.

const strWithEmail    = "My email address is jeff@jeff.com";
const strWithoutEmail = "My email address is above";
EmailUtil.extract(strWithEmail)   # => "jeff@jeff.com"
EmailUtil.extract(strWithoutEmai) # => false

Tests

Run tests with npm test.

Package Sidebar

Install

npm i email-address-util

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

23.6 kB

Total Files

4

Last publish

Collaborators

  • ajaygandhi