@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.
31 lines • 1.08 kB
JavaScript
/**
* 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
*/
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = isEmail;
function isEmail(email) {
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return emailRegex.test(email);
}
});
//# sourceMappingURL=isEmail.js.map