459396af6fa1ae1290cc2de8994a5d23a985cf15
1 function checkChallenge(c
)
3 const vid
= parseInt(c
.vid
);
4 if (isNaN(vid
) || vid
<= 0)
5 return "Please select a variant";
7 const mainTime
= parseInt(c
.mainTime
);
8 const increment
= parseInt(c
.increment
);
9 if (isNaN(mainTime
) || mainTime
<= 0)
10 return "Main time should be strictly positive";
11 if (isNaN(increment
) || increment
< 0)
12 return "Increment must be positive";
14 // Basic alphanumeric check for players names
18 if (p
.name
.length
> 0)
20 if (!p
.name
.match(/^[\w]+$/))
21 return "Wrong characters in players names";
26 if (playerCount
> 0 && playerCount
!= c
.nbPlayers
-1)
27 return "None, or all of the opponent names must be filled"
29 // Just characters check on server:
30 if (!c
.fen
.match(/^[a-zA-Z0-9, /-]*$/))
31 return "Bad FEN string";
34 module
.exports
= checkChallenge
;