User management logic half-debugged
[vchess.git] / public / javascripts / shared / userCheck.js
diff --git a/public/javascripts/shared/userCheck.js b/public/javascripts/shared/userCheck.js
new file mode 100644 (file)
index 0000000..bd282ba
--- /dev/null
@@ -0,0 +1,19 @@
+function checkNameEmail(o)
+{
+       if (!!o.name)
+       {
+               if (o.name.length == 0)
+                       return "Empty name";
+               if (!o.name.match(/^[\w]+$/))
+                       return "Bad characters in name";
+       }
+       if (!!o.email)
+       {
+               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