gleezo-email-tester
v1.0.8
Published
Module that checks if email is valid.
Downloads
5
Readme
gleezo-email-tester
Module that checks if email is valid. Regexp used in this module is according to: http://emailregex.com/.
Methods
Setup
To setup:
const EmailTester = require('gleezo-email-tester');
const Logger = require('some-logger'); // <-- any logger, that has 'error' method
const logger = new Logger();
const emailTester = new EmailTester(logger);
Test
If email is not valid - will log error. Usage:
emailTester.test('[email protected]', req); // true
emailTester.test('{$exists: true}', req); // false + logs error
TestEach
Same as test, but accepts array of emails
emailTester.testEach(['[email protected]'], req); // true
emailTester.testEach(['[email protected]', '{$exists: true}'], req); // false + logs error
Check
Simply checks if email is valid
emailTester.test('[email protected]', req); // true
emailTester.test('{$exists: true}', req); // false