1 import { extractTime
} from "@/utils/timeControl";
3 export function checkChallenge(c
)
5 const vid
= parseInt(c
.vid
);
6 if (isNaN(vid
) || vid
<= 0)
7 return "Please select a variant";
9 const tc
= extractTime(c
.cadence
);
11 return "Wrong time control";
13 // Basic alphanumeric check for opponent name
16 // NOTE: slightly redundant (see data/userCheck.js)
17 if (!c
.to
.match(/^[\w]+$/))
18 return "Wrong characters in opponent name";
21 // Allow custom FEN (and check it) only for individual challenges
22 if (c
.fen
.length
> 0 && !!c
.to
)
24 if (!V
.IsGoodFen(c
.fen
))
25 return "Bad FEN string";