mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-03-29 05:44:46 -05:00
63 lines
1.3 KiB
TypeScript
63 lines
1.3 KiB
TypeScript
import * as z from "zod";
|
|
|
|
export const EVENT_DESCRIPTION_LIMIT = 2000;
|
|
|
|
export const eventSchema = z.object({
|
|
name: z.string().min(5).max(100),
|
|
description: z.string().max(EVENT_DESCRIPTION_LIMIT),
|
|
date: z.string().refine(
|
|
(valString) => {
|
|
const val = new Date(valString);
|
|
const now = new Date();
|
|
if (now.getTime() > val.getTime()) return false;
|
|
|
|
now.setMonth(now.getMonth() + 12);
|
|
|
|
if (now.getTime() < val.getTime()) return false;
|
|
|
|
return true;
|
|
},
|
|
{ message: "Date of the tournament has to be in the following 12 months." }
|
|
),
|
|
eventUrl: z.string().url(),
|
|
discordInviteUrl: z
|
|
.string()
|
|
.url()
|
|
.refine(
|
|
(val) =>
|
|
val.startsWith("https://discord.io/") ||
|
|
val.startsWith("https://discord.gg/"),
|
|
{
|
|
message:
|
|
"Has to start with 'https://discord.gg/' or 'https://discord.io/'",
|
|
}
|
|
),
|
|
tags: z.array(
|
|
z.enum([
|
|
"SZ",
|
|
"TW",
|
|
"SPECIAL",
|
|
"ART",
|
|
"MONEY",
|
|
"REGION",
|
|
"LOW",
|
|
"COUNT",
|
|
"MULTIPLE",
|
|
"S1",
|
|
"LAN",
|
|
"QUALIFIER",
|
|
])
|
|
),
|
|
//isTournament: z.boolean(),
|
|
format: z.enum([
|
|
"SE",
|
|
"DE",
|
|
"GROUPS2SE",
|
|
"GROUPS2DE",
|
|
"SWISS2SE",
|
|
"SWISS2DE",
|
|
"SWISS",
|
|
"OTHER",
|
|
]),
|
|
});
|