UNPKG

@azizbecha/strkit

Version:

strkit is a utility library offering a collection of essential string functions including validation, case conversion, truncation, and more. Ideal for both JavaScript and TypeScript developers to simplify string operations in their applications.

18 lines 614 B
/** * Validates whether a given string is a valid email address. * * This function uses a regular expression to check if the input string * adheres to the standard email address format (e.g., "user@example.com"). * * @param email - The string to validate as an email address. * @returns `true` if the string is a valid email, otherwise `false`. * * @example * isEmail('test@example.com'); // true * isEmail('not-an-email'); // false */ export default function isEmail(email) { const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; return emailRegex.test(email); } //# sourceMappingURL=isEmail.js.map