The string to validate as an email address
Custom regular expression to use for validation against provided value.
Defaults to EMAIL_REGEX_PRESETS.strict, which is designed to cover common email formats while excluding complex edge cases.
true if the string is a valid email; otherwise, false.
This function validates the input using a practical regular expression (EMAIL_REGEX_PRESETS.strict) that supports most common email formats while intentionally ignoring edge cases defined by full RFC 5322.
Validation is fully delegated to the provided regex, which ensures:
@ symbolLimits enforced:
isEmail('user@example.com'); // true
isEmail('first.last@college.university.in'); // true
isEmail('invalid-email'); // false
isEmail('name@domain'); // false
const ONLY_EXAMPLE_DOMAIN = /^[^@]+@example\.com$/;
isEmail('user@example.com', ONLY_EXAMPLE_DOMAIN); // true
isEmail('user@gmail.com', ONLY_EXAMPLE_DOMAIN); // false
EMAIL_REGEX_PRESETS.strict for the default regular expression used in validation.
Checks whether a given string is a valid email address.