Started code review + some fixes (unfinished)
[vchess.git] / client / src / data / userCheck.js
index 65ed1db..dac8ef6 100644 (file)
@@ -1,19 +1,11 @@
-function checkNameEmail(o)
-{
-       if (typeof o.name === "string")
-       {
-               if (o.name.length == 0)
-                       return "Empty name";
-               if (!o.name.match(/^[\w]+$/))
-                       return "Bad characters in name";
-       }
-       if (typeof o.email === "string")
-       {
-               if (o.email.length == 0)
-                       return "Empty email";
-               if (!o.email.match(/^[\w.+-]+@[\w.+-]+$/))
-                       return "Bad characters in email";
-       }
+export function checkNameEmail(o) {
+  if (typeof o.name === "string") {
+    if (o.name.length == 0) return "Empty name";
+    if (!o.name.match(/^[\w]+$/)) return "Bad characters in name";
+  }
+  if (typeof o.email === "string") {
+    if (o.email.length == 0) return "Empty email";
+    if (!o.email.match(/^[\w.+-]+@[\w.+-]+$/)) return "Bad characters in email";
+  }
+  return "";
 }
-
-try { module.exports = checkNameEmail; } catch(e) { } //for server