Skip to main content

isValidEmail

A function that checks whether a given string conforms to the email format.

It uses a regular expression based on the RFC 5322 standard, and the regex used in this function can validate 99.99% of email formats.

Note that a perfect email regular expression does not exist, hence 99.99%.


Code

🔗 View source code


Interface

typescript
const isValidEmail: (email: string) => boolean

Usage

typescript
import { isValidEmail } from '@modern-kit/utils';

const isEmail1 = isValidEmail('example@email.com'); // true
const isEmail2 = isValidEmail('invalid-email'); // false

References