@beenotung/tslib
Version:
utils library in Typescript
31 lines (30 loc) • 1.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.to_full_hk_mobile_phone = exports.is_hk_mobile_phone = exports.is_hk_mobile_phone_prefix = void 0;
exports.is_email = is_email;
var tel_1 = require("./tel");
Object.defineProperty(exports, "is_hk_mobile_phone_prefix", { enumerable: true, get: function () { return tel_1.is_hk_mobile_phone_prefix; } });
Object.defineProperty(exports, "is_hk_mobile_phone", { enumerable: true, get: function () { return tel_1.is_hk_mobile_phone; } });
Object.defineProperty(exports, "to_full_hk_mobile_phone", { enumerable: true, get: function () { return tel_1.to_full_hk_mobile_phone; } });
function is_email(s) {
if (!s) {
return false;
}
const ss = s.split('@');
if (ss.length !== 2) {
return false;
}
const domain = ss[1];
if (domain !== domain.trim()) {
return false;
}
const names = domain.split('.');
if (names.some(s => !s) || names.length < 2) {
return false;
}
const username = ss[0];
if (username !== username.trim()) {
return false;
}
return username.length > 0;
}