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