From 31177fba1b90bc106fa640f87e6dac24e3a1d17d Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Mon, 13 Oct 2025 18:18:40 +0000 Subject: [PATCH] Fix founded_year empty string validation --- src/lib/entityValidationSchemas.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/entityValidationSchemas.ts b/src/lib/entityValidationSchemas.ts index 78086300..e4815198 100644 --- a/src/lib/entityValidationSchemas.ts +++ b/src/lib/entityValidationSchemas.ts @@ -104,7 +104,10 @@ export const companyValidationSchema = z.object({ // Support both founded_date (preferred) and founded_year (legacy) founded_date: z.string().optional(), founded_date_precision: z.enum(['day', 'month', 'year']).optional(), - founded_year: z.coerce.number().int().min(1800).max(currentYear).optional().nullable(), + founded_year: z.preprocess( + (val) => val === '' || val === null || val === undefined ? undefined : val, + z.coerce.number().int().min(1800).max(currentYear).optional() + ).optional().nullable(), headquarters_location: z.string().max(200, 'Location must be less than 200 characters').optional(), website_url: z.string().optional().refine((val) => { if (!val || val === '') return true;