- if (!!obj.move)
- {
- if (!obj.move.played.toString().match(/^[0-9]+$/))
- return "Wrong move played time";
- if (!obj.move.idx.toString().match(/^[0-9]+$/))
- return "Wrong move index";
- }
- if (!!obj.drawOffer && !obj.drawOffer.match(/^[wbtn]$/))
- return "Wrong draw offer format";
- if (!!obj.fen && !obj.fen.match(/^[a-zA-Z0-9, /-]*$/))
- return "Wrong FEN string";
- if (!!obj.score && !obj.score.match(/^[012?*\/-]+$/))
- return "Wrong characters in score";
- if (!!obj.scoreMsg && !obj.scoreMsg.match(/^[a-zA-Z ]+$/))
- return "Wrong characters in score message";
- if (!!obj.chat)
- return UserModel.checkNameEmail({name: obj.chat.name});
- return "";
+ return (
+ (
+ !obj.move || (
+ !!(obj.move.played.toString().match(/^[0-9]+$/)) &&
+ !!(obj.move.idx.toString().match(/^[0-9]+$/))
+ )
+ ) && (
+ !obj.drawOffer || !!(obj.drawOffer.match(/^[wbtn]$/))
+ ) && (
+ !obj.fen || !!(obj.fen.match(/^[a-zA-Z0-9, /-]*$/))
+ ) && (
+ !obj.score || !!(obj.score.match(/^[012?*\/-]+$/))
+ ) && (
+ !obj.scoreMsg || !!(obj.scoreMsg.match(/^[a-zA-Z ]+$/))
+ ) && (
+ !obj.chat || UserModel.checkNameEmail({name: obj.chat.name})
+ )
+ );