mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 17:51:14 -05:00
Fix: Correct founded year validation
This commit is contained in:
@@ -20,7 +20,12 @@ const designerSchema = z.object({
|
||||
description: z.string().optional(),
|
||||
person_type: z.enum(['company', 'individual', 'firm', 'organization']),
|
||||
website_url: z.string().url().optional().or(z.literal('')),
|
||||
founded_year: z.number().min(1800).max(new Date().getFullYear()).optional(),
|
||||
founded_year: z.string()
|
||||
.optional()
|
||||
.transform(val => val === '' || val === undefined ? undefined : Number(val))
|
||||
.refine(val => val === undefined || (!isNaN(val) && val >= 1800 && val <= new Date().getFullYear()), {
|
||||
message: "Founded year must be between 1800 and current year"
|
||||
}),
|
||||
headquarters_location: z.string().optional(),
|
||||
images: z.object({
|
||||
uploaded: z.array(z.object({
|
||||
@@ -147,7 +152,7 @@ export function DesignerForm({ onSubmit, onCancel, initialData }: DesignerFormPr
|
||||
type="number"
|
||||
min="1800"
|
||||
max={new Date().getFullYear()}
|
||||
{...register('founded_year', { valueAsNumber: true })}
|
||||
{...register('founded_year')}
|
||||
placeholder="e.g. 1972"
|
||||
/>
|
||||
{errors.founded_year && (
|
||||
|
||||
Reference in New Issue
Block a user