Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Reject number lead form fields whose minimum is more than the maximum

Rafi40684f850ad0
diff --git a/apps/web/lib/zod/schemas/submitted-lead-form.ts b/apps/web/lib/zod/schemas/submitted-lead-form.ts
index 08cd5a6e25..ec8f769026 100644
--- a/apps/web/lib/zod/schemas/submitted-lead-form.ts
+++ b/apps/web/lib/zod/schemas/submitted-lead-form.ts
@@ -76,6 +76,10 @@ export const numberFieldSchema = fieldCommonSchema.extend({
min: z.number().optional(),
max: z.number().optional(),
})
+ .refine(
+ ({ min, max }) => min === undefined || max === undefined || min <= max,
+ { message: "The minimum can't be more than the maximum." },
+ )
.optional(),
});