The isEmail
function checks if the input string is a valid email address. It returns true
if the email address is valid and follows the supported format, and false
otherwise.
This function just checks the syntax of the email to see if it's valid or not, if you need a stronger validation, use: validateEmail
The function can be imported using ES6 syntax from the "multiform-validator" package:
import { isEmail } from 'multiform-validator';
Alternatively, you can import the function using CommonJS syntax with require
(Node.js):
const { isEmail } = require('multiform-validator');
The function takes one parameter:
email
(string) - The input string representing the email address to validate.// Example - Valid email address
const result1 = isEmail('foor@bar.com');
console.log(result1); // true
The function expects the input email to be passed as a string. If the input is not a string, it will throw an error. If the email passed is an invalid email, it will return. false
.