From ed705966196c942738675f0679f765dbd4011757 Mon Sep 17 00:00:00 2001 From: trafficlunar Date: Thu, 9 Apr 2026 12:51:33 +0100 Subject: [PATCH] fix: youtubeId should be null not empty on submit form --- src/app/api/submit/route.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/api/submit/route.ts b/src/app/api/submit/route.ts index e34bc66..b48ddeb 100644 --- a/src/app/api/submit/route.ts +++ b/src/app/api/submit/route.ts @@ -39,8 +39,9 @@ const submitSchema = z miiFeaturesImage: z.union([z.instanceof(File), z.any()]).optional(), youtubeId: z .string() - .regex(/^[a-zA-Z0-9_-]{11}$/, "Invalid YouTube video ID") - .or(z.literal("")) + .trim() + .transform((val) => (val === "" ? null : val)) + .refine((val) => val === null || /^[a-zA-Z0-9_-]{11}$/.test(val), "Invalid YouTube video ID") .optional(), instructions: switchMiiInstructionsSchema,