Separate client and server codes. Keep everything in one git repo for simplicity
[vchess.git] / server / data / userCheck.js
diff --git a/server/data/userCheck.js b/server/data/userCheck.js
new file mode 100644 (file)
index 0000000..9c46b2a
--- /dev/null
@@ -0,0 +1,19 @@
+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";
+       }
+}
+
+module.exports = checkNameEmail;