The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add character validation for discount codes
Kiran K93c20e4a0de0
diff --git a/apps/web/lib/zod/schemas/discount.ts b/apps/web/lib/zod/schemas/discount.tsindex 194d6d422f..cb0797ca2b 100644--- a/apps/web/lib/zod/schemas/discount.ts+++ b/apps/web/lib/zod/schemas/discount.ts@@ -73,8 +73,14 @@ export const DiscountCodeSchema = z.object({export const createDiscountCodeSchema = z.object({code: z.string()+ .trim().max(100, "Code must be less than 100 characters.")- .optional(),+ .regex(+ /^[a-zA-Z0-9\-_]+$/,+ "Code can only contain letters, numbers, dashes, and underscores.",+ )+ .optional()+ .or(z.literal("").transform(() => undefined)),partnerId: z.string(),linkId: z.string(),});