import moment from "moment-timezone"; import { z } from "zod"; export const zodId = z .string() .refine((value) => /^\d{7,20}$/.test(value), "Invalid ID supplied") .transform((value) => parseInt(value)); export const zodTpMessages = z.object({ channelId: zodId, messageIds: z.object({ "0": zodId.nullable(), "1": zodId.nullable(), "2": zodId.nullable(), "3": zodId.nullable(), "4": zodId.nullable(), "5": zodId.nullable(), "6": zodId.nullable(), }), }); export const zodMatch = z.object({ match: z.object({ channelId: zodId, createrId: zodId, messageId: zodId, roleId: zodId, matchType: z.string(), opponentName: z.string(), utc_ts: z.string().datetime(), }), timezone: z .string() .refine( (value) => moment.tz.names().includes(value), "Unknown timezone supplied", ), });