Separate client and server codes. Keep everything in one git repo for simplicity
[vchess.git] / client / client_OLD / javascripts / shared / userCheck.js
diff --git a/client/client_OLD/javascripts/shared/userCheck.js b/client/client_OLD/javascripts/shared/userCheck.js
new file mode 100644 (file)
index 0000000..65ed1db
--- /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";
+       }
+}
+
+try { module.exports = checkNameEmail; } catch(e) { } //for server