Skip to content
This repository was archived by the owner on Jan 17, 2022. It is now read-only.

e-conomic/email-address

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Archived

Tech Leads: Repository archived due to inactivity in more than 6 months. Please remember to add a CODEOWNERS file to the root of the repository when unarchiving.

Email address helpers Build Status

Regular expressions ensuring the given input is a valid address.

This module ensure that we use the same approach for validating a given email address across all our services. It was originally lifted from the debitoor-app source/util-folder into its own module.

Overview

Helper functions

Two helper functions, isValid and isMultipleValid, are exposed. isValid is basically a wrapper calling .single.test from the regex section on the input, and isMultipleValid splits a string on commas (,), and verify that every item is a valid email address.

Usage:

var email = require('email-address');
email.isValid('[email protected]'); // true
email.isValid('foo bar'); // false
email.isMultipleValid('[email protected],[email protected]'); // true
email.isMultipleValid('[email protected],[email protected]'); // false

Regexes

The following regexes are exposed:

  • .single the string is a valid email address.
  • .multiple the string is a comma seperated list of valid email addresses. Whitespace are allowed between the email addresses.
  • .optional the string is a valid email address or an empty string.

Usage:

var email = require('email-address');

// input is a vaild email address
email.single.test('[email protected]'); // true

// input is a comma seperated list of valid email addresses
email.multiple.test('[email protected], [email protected]'); // true

// input is a valid email address, or an empty string
email.optional.test('[email protected]'); // true
email.optional.test(''); // true

About

node.js module for email address magick

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •