The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add min and max limits to the number lead form field
Rafi3bf23be4505d
diff --git a/apps/web/lib/zod/schemas/submitted-lead-form.ts b/apps/web/lib/zod/schemas/submitted-lead-form.tsindex ce46b0f854..08cd5a6e25 100644--- a/apps/web/lib/zod/schemas/submitted-lead-form.ts+++ b/apps/web/lib/zod/schemas/submitted-lead-form.ts@@ -71,6 +71,12 @@ export const multiSelectFieldSchema = fieldCommonSchema.extend({// Numberexport const numberFieldSchema = fieldCommonSchema.extend({type: z.literal("number"),+ constraints: z+ .object({+ min: z.number().optional(),+ max: z.number().optional(),+ })+ .optional(),});// Phone Numberdiff --git a/apps/web/ui/submitted-leads/form-fields/number-field.tsx b/apps/web/ui/submitted-leads/form-fields/number-field.tsxindex 1db6a79d26..6572e72b6c 100644--- a/apps/web/ui/submitted-leads/form-fields/number-field.tsx+++ b/apps/web/ui/submitted-leads/form-fields/number-field.tsx@@ -17,6 +17,8 @@ export function NumberField({const keyPath = keyPathProp || `formData.${field.key}`;const state = getFieldState(keyPath);const error = !!state.error;+ const min = field.constraints?.min;+ const max = field.constraints?.max;return (<FormControl@@ -27,6 +29,8 @@ export function NumberField({><inputtype="number"+ min={min}+ max={max}className={cn("mt-2 block w-full rounded-md text-sm focus:outline-none",error@@ -36,6 +40,12 @@ export function NumberField({{...register(keyPath, {required: field.required,valueAsNumber: true,+ ...(min !== undefined && {+ min: { value: min, message: `Must be at least ${min}` },+ }),+ ...(max !== undefined && {+ max: { value: max, message: `Must be at most ${max}` },+ }),})}/></FormControl>