![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
isemail
Advanced tools
Package description
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.
Readme
This first version of isemail
is a port of the PHP is_email
function by Dominic Sayers.
Future versions will improve upon the current version, optimizing it for efficient usage and DRYing the code.
$ npm install isemail
The tests were pulled from is_email's extensive test suite on October 15, 2013. Many thanks to the contributors!
Run any of the following.
$ mocha
$ npm test
$ make test
remember to npm install
!
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
and checkDNS
. The callback
function will always be called if specified, and the result of the operation supplied as the only parameter to the callback function. If isEmail
is not asked to check for the existence of the domain (checkDNS
), it will also synchronously return the result of the operation.
Use errorLevel
to specify the type of result for isEmail
. 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.
$ node
> var isEmail = require('isemail');
undefined
> var log = console.log.bind(console, 'result');
undefined
> isEmail('test@iana.org');
true
> isEmail('test@iana.org', log);
result true
true
> isEmail('test@iana.org', {checkDNS: true});
undefined
> isEmail('test@iana.org', {checkDNS: true}, log);
undefined
result true
> isEmail('test@iana.org', {errorLevel: true});
0
> isEmail('test@iana.org', {errorLevel: true}, log);
result 0
0
> isEmail('test@e.com');
true
> isEmail('test@e.com', {checkDNS: true, errorLevel: true}, log);
undefined
result 6
> isEmail('test@e.com', {checkDNS: true, errorLevel: 7}, log);
undefined
result 0
> isEmail('test@e.com', {checkDNS: true, errorLevel: 6}, log);
undefined
result 6
Add tests for library usage, not just functionality comparisons.
FAQs
Validate an email address according to RFCs 5321, 5322, and others
The npm package isemail receives a total of 815,956 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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.