
Security News
libxml2 Maintainer Ends Embargoed Vulnerability Reports, Citing Unsustainable Burden
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
The isemail npm package is a module that allows you to validate email addresses according to the standards and specifications of the Internet Message Format and the DNS (Domain Name System). It is designed to ensure that email addresses are syntactically correct and can be used for sending and receiving emails.
Email Validation
This feature allows you to validate whether a string is a valid email address. It returns a boolean indicating whether the email is valid or not.
const isEmail = require('isemail');
console.log(isEmail.validate('test@example.com')); // true
console.log(isEmail.validate('invalid-email')); // false
Check DNS
This feature enables DNS checking as part of the validation process. It performs an asynchronous DNS lookup to see if the domain in the email address exists.
const isEmail = require('isemail');
isEmail.validate('test@example.com', { checkDNS: true }, (err, isValid) => {
console.log(isValid); // true or false based on DNS check
});
Error Level Reporting
This feature provides detailed error level reporting. Instead of a simple boolean, it returns a numeric error level indicating the type of validation error, if any.
const isEmail = require('isemail');
const result = isEmail.validate('test@example.com', { errorLevel: true });
console.log(result); // 0 for valid email or a positive number representing the error level
Validator is a library of string validators and sanitizers. It provides a simple way to validate emails with the isEmail function, among many other validation functions. It is more comprehensive than isemail as it includes a wide range of validation and sanitization methods for different data types.
Email-validator is a package specifically focused on email address validation. It offers a simple API with a single validate method. It is similar to isemail but does not provide DNS checking or detailed error level reporting.
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. Options may include errorLevel
.
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.
The allowUnicode
option governs whether non-ASCII characters are allowed. Defaults to true
per RFC 6530.
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.
As of 3.1.1
, the callback
parameter is deprecated, and will be removed in 4.0.0
.
$ node
> var Isemail = require('isemail');
undefined
> Isemail.validate('test@iana.org');
true
> Isemail.validate('test@iana.123');
true
> Isemail.validate('test@iana.org', {errorLevel: true});
0
> Isemail.validate('test@iana.123', {errorLevel: true});
10
> Isemail.validate('test@iana.123', {errorLevel: 17});
0
> Isemail.validate('test@iana.123', {errorLevel: 10});
10
> Isemail.validate('test@iana&12');
false
> Isemail.validate('test@iana&12', {errorLevel: true});
65
> Isemail.validate('test@', {errorLevel: true});
131
[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 isemail receives a total of 683,103 weekly downloads. As such, isemail popularity was classified as popular.
We found that isemail demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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.
Security News
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.