Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@anchorchat/isemail
Advanced tools
Validate an email address according to RFCs 5321, 5322, and others
Node email address validation library
Lead Maintainer: Eli Skeggs
This library is a port of the PHP is_email
function by Dominic Sayers.
$ npm install isemail
The tests were pulled from is_email
's extensive test suite on October 15, 2013. Many thanks to the contributors! Additional tests have been added to increase code coverage and verify edge-cases.
Run any of the following.
$ lab
$ npm test
$ make test
remember to npm install
to get the development dependencies!
Determines whether the email
is valid or not, for various definitions thereof. Optionally accepts an options
object and a callback
function. Options may include errorLevel
. The callback
function will always be called if specified, and the result of the operation supplied as the only parameter to the callback function. validate()
will synchronously return the result of the operation if no callback is provided.
Use errorLevel
to specify the type of result for validate()
. Passing a false
literal will result in a true or false boolean indicating whether the email address is sufficiently defined for use in sending an email. Passing a true
literal will result in a more granular numeric status, with zero being a perfectly valid email address. Passing a number will return 0
if the numeric status is below the errorLevel
and the numeric status otherwise.
The tldBlacklist
option can be either an object lookup table or an array of invalid top-level domains. If the email address has a top-level domain that is in the whitelist, the email will be marked as invalid.
The tldWhitelist
option can be either an object lookup table or an array of valid top-level domains. If the email address has a top-level domain that is not in the whitelist, the email will be marked as invalid.
Only one of tldBlacklist
and tldWhitelist
will be consulted for TLD validity.
The minDomainAtoms
option is an optional positive integer that specifies the minimum number of domain atoms that must be included for the email address to be considered valid. Be careful with the option, as some top-level domains, like io
, directly support email addresses.
$ node
> var Isemail = require('isemail');
undefined
> var log = console.log.bind(console, 'result');
undefined
> Isemail.validate('test@iana.org');
true
> Isemail.validate('test@iana.org', log);
result true
true
> Isemail.validate('test@iana.org');
undefined
> Isemail.validate('test@iana.org', {errorLevel: true});
0
> Isemail.validate('test@iana.org', {errorLevel: true}, log);
result 0
0
> Isemail.validate('test@e.com');
true
> Isemail.validate('test@e.com', {errorLevel: true}, log);
undefined
result 6
> Isemail.validate('test@e.com', {errorLevel: 7}, log);
undefined
result 0
> Isemail.validate('test@e.com', {errorLevel: 6}, log);
undefined
result 6
[1]: if this badge indicates the build is passing, then isemail has 100% code coverage.
FAQs
Validate an email address according to RFCs 5321, 5322, and others
The npm package @anchorchat/isemail receives a total of 2 weekly downloads. As such, @anchorchat/isemail popularity was classified as not popular.
We found that @anchorchat/isemail demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.