Prevent creation of tournaments without tiebreaker map pool if required by the format selected
Some checks failed
Tests and checks on push / run-checks-and-tests (push) Has been cancelled
Updates translation progress / update-translation-progress-issue (push) Has been cancelled

This commit is contained in:
Kalle
2024-11-26 22:17:03 +02:00
parent 2a0c843298
commit 56a222cbf2

View File

@@ -324,4 +324,22 @@ export const newCalendarEventActionSchema = z
{
message: "Tournament must have exactly one date",
},
)
.refine(
(schema) => {
if (schema.toToolsMode !== "ALL") {
return true;
}
const maps = schema.pool ? MapPool.toDbList(schema.pool) : [];
return (
maps.length === 4 &&
rankedModesShort.every((mode) => maps.some((map) => map.mode === mode))
);
},
{
message:
'Map pool must contain a map for each ranked mode if using "Prepicked by teams - All modes"',
},
);