mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 06:11:12 -05:00
Fix founded year/date handling
This commit is contained in:
@@ -101,18 +101,10 @@ export const companyValidationSchema = z.object({
|
||||
company_type: z.enum(['manufacturer', 'designer', 'operator', 'property_owner']),
|
||||
description: z.string().max(2000, 'Description must be less than 2000 characters').optional(),
|
||||
person_type: z.enum(['company', 'individual', 'firm', 'organization']),
|
||||
founded_year: z.string()
|
||||
.optional()
|
||||
.transform(val => {
|
||||
if (!val || val.trim() === '') return undefined;
|
||||
const num = Number(val);
|
||||
return isNaN(num) ? undefined : num;
|
||||
})
|
||||
.refine(val => val === undefined || (typeof val === 'number' && val >= 1800 && val <= currentYear), {
|
||||
message: `Founded year must be between 1800 and ${currentYear}`
|
||||
}),
|
||||
// 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.number().int().min(1800).max(currentYear).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;
|
||||
|
||||
Reference in New Issue
Block a user