X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fdata%2FuserCheck.js;h=0d3a801bd18e79d461d8e0ee22f25e1c58b1d207;hb=7ba4a5bc5b64e19a1e7f26aa232d5c50770d07ad;hp=4c714a681099df906184d7dbe800a4bc27d23031;hpb=9d58ef95e3affd799571838164f7c5bbfda11f64;p=vchess.git diff --git a/client/src/data/userCheck.js b/client/src/data/userCheck.js index 4c714a68..0d3a801b 100644 --- a/client/src/data/userCheck.js +++ b/client/src/data/userCheck.js @@ -1,17 +1,13 @@ -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"; - } +export function checkNameEmail(o) { + if (typeof o.name === "string") { + if (o.name.length == 0) return "Missing name"; + if (!o.name.match(/^[\w-]+$/)) return "Name: alphanumerics, hyphen and underscore"; + } + + if (typeof o.email === "string") { + if (o.email.length == 0) return "Missing email"; + if (!o.email.match(/^[\w.+-]+@[\w.+-]+$/)) return "Invalid email"; + } + + return ""; }