Files
cloudron-box/src/validator.js
Girish Ramakrishnan 12e073e8cf use node: prefix for requires
mostly because code is being autogenerated by all the AI stuff using
this prefix. it's also used in the stack trace.
2025-08-14 12:55:35 +05:30

18 lines
395 B
JavaScript

'use strict';
exports = module.exports = {
isEmail
};
const assert = require('node:assert');
// this currently does not match: "john.doe"@example.com, user@[192.168.1.1], john.doe(comment)@example.com or 用户@例子.世界
function isEmail(email) {
assert.strictEqual(typeof email, 'string');
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return emailRegex.test(email);
}