The Email Formatter library helps format email addresses according to specific rules.
You can install this library via npm by running the following command:
npm install email-formatter
Or if you are using yarn, run:
yarn add email-formatter
First, import the library into your project:
const emailFormatter = require('email-formatter');
Then, you can use the emailFormatter function to format email addresses:
const formattedEmail = emailFormatter('Your.email@gmail.com');
console.log(formattedEmail); // Output: 'youremail@gmail.com'
This library provides a emailFormatter
function that takes an email address as input and returns the formatted email address. If the email address is not valid, the function will return null
.
The formatting rules for email are as follows:
-
If the email domain is
googlemail.com
orgmail.com
, all dots in the username part will be removed, and the domain will be changed togmail.com
. -
All characters in the email will be converted to lowercase.
This library simply checks email formatting using a regular expression. It does not perform any other form of email validation.