0d3a801bd18e79d461d8e0ee22f25e1c58b1d207
[vchess.git] / client / src / data / userCheck.js
1 export function checkNameEmail(o) {
2 if (typeof o.name === "string") {
3 if (o.name.length == 0) return "Missing name";
4 if (!o.name.match(/^[\w-]+$/)) return "Name: alphanumerics, hyphen and underscore";
5 }
6
7 if (typeof o.email === "string") {
8 if (o.email.length == 0) return "Missing email";
9 if (!o.email.match(/^[\w.+-]+@[\w.+-]+$/)) return "Invalid email";
10 }
11
12 return "";
13 }