|
|
|
|
@@ -25,24 +25,24 @@ const imageAssignmentSchema = z.object({
|
|
|
|
|
export const parkValidationSchema = z.object({
|
|
|
|
|
name: z.string().trim().min(1, 'Park name is required').max(200, 'Name must be less than 200 characters'),
|
|
|
|
|
slug: z.string().trim().min(1, 'Slug is required').regex(/^[a-z0-9-]+$/, 'Slug must contain only lowercase letters, numbers, and hyphens'),
|
|
|
|
|
description: z.string().trim().max(2000, 'Description must be less than 2000 characters').optional().or(z.literal('')),
|
|
|
|
|
description: z.string().trim().max(2000, 'Description must be less than 2000 characters').nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
park_type: z.string().min(1, 'Park type is required'),
|
|
|
|
|
status: z.enum(['operating', 'closed_permanently', 'closed_temporarily', 'under_construction', 'planned', 'abandoned']),
|
|
|
|
|
opening_date: z.string().optional().or(z.literal('')).refine((val) => {
|
|
|
|
|
opening_date: z.string().nullable().optional().or(z.literal('')).transform(val => val || undefined).refine((val) => {
|
|
|
|
|
if (!val) return true;
|
|
|
|
|
const date = new Date(val);
|
|
|
|
|
return date <= new Date();
|
|
|
|
|
}, 'Opening date cannot be in the future'),
|
|
|
|
|
opening_date_precision: z.enum(['day', 'month', 'year']).optional(),
|
|
|
|
|
closing_date: z.string().optional().or(z.literal('')),
|
|
|
|
|
closing_date_precision: z.enum(['day', 'month', 'year']).optional(),
|
|
|
|
|
opening_date_precision: z.enum(['day', 'month', 'year']).nullable().optional(),
|
|
|
|
|
closing_date: z.string().nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
closing_date_precision: z.enum(['day', 'month', 'year']).nullable().optional(),
|
|
|
|
|
location_id: z.string().uuid().optional().nullable(),
|
|
|
|
|
website_url: z.string().trim().optional().or(z.literal('')).refine((val) => {
|
|
|
|
|
website_url: z.string().trim().nullable().optional().or(z.literal('')).transform(val => val || undefined).refine((val) => {
|
|
|
|
|
if (!val || val === '') return true;
|
|
|
|
|
return z.string().url().safeParse(val).success;
|
|
|
|
|
}, 'Invalid URL format'),
|
|
|
|
|
phone: z.string().trim().max(50, 'Phone must be less than 50 characters').optional().or(z.literal('')),
|
|
|
|
|
email: z.string().trim().optional().or(z.literal('')).refine((val) => {
|
|
|
|
|
phone: z.string().trim().max(50, 'Phone must be less than 50 characters').nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
email: z.string().trim().nullable().optional().or(z.literal('')).transform(val => val || undefined).refine((val) => {
|
|
|
|
|
if (!val || val === '') return true;
|
|
|
|
|
return z.string().email().safeParse(val).success;
|
|
|
|
|
}, 'Invalid email format'),
|
|
|
|
|
@@ -64,19 +64,21 @@ export const parkValidationSchema = z.object({
|
|
|
|
|
.nullable()
|
|
|
|
|
.or(z.literal(''))
|
|
|
|
|
.transform(val => val || undefined),
|
|
|
|
|
banner_image_id: z.string().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
banner_image_url: z.string().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
card_image_id: z.string().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
card_image_url: z.string().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
banner_image_id: z.string().nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
banner_image_url: z.string().nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
card_image_id: z.string().nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
card_image_url: z.string().nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
images: imageAssignmentSchema,
|
|
|
|
|
source_url: z.string().trim().optional().or(z.literal('')).refine((val) => {
|
|
|
|
|
source_url: z.string().trim().nullable().optional().or(z.literal('')).transform(val => val || undefined).refine((val) => {
|
|
|
|
|
if (!val || val === '') return true;
|
|
|
|
|
return z.string().url().safeParse(val).success;
|
|
|
|
|
}, 'Invalid URL format. Must be a valid URL starting with http:// or https://'),
|
|
|
|
|
submission_notes: z.string().trim()
|
|
|
|
|
.max(1000, 'Submission notes must be less than 1000 characters')
|
|
|
|
|
.nullable()
|
|
|
|
|
.optional()
|
|
|
|
|
.or(z.literal('')),
|
|
|
|
|
.or(z.literal(''))
|
|
|
|
|
.transform(val => val || undefined),
|
|
|
|
|
}).refine((data) => {
|
|
|
|
|
if (data.closing_date && data.opening_date) {
|
|
|
|
|
return new Date(data.closing_date) >= new Date(data.opening_date);
|
|
|
|
|
@@ -94,9 +96,9 @@ export const parkValidationSchema = z.object({
|
|
|
|
|
export const rideValidationSchema = z.object({
|
|
|
|
|
name: z.string().trim().min(1, 'Ride name is required').max(200, 'Name must be less than 200 characters'),
|
|
|
|
|
slug: z.string().trim().min(1, 'Slug is required').regex(/^[a-z0-9-]+$/, 'Slug must contain only lowercase letters, numbers, and hyphens'),
|
|
|
|
|
description: z.string().trim().max(2000, 'Description must be less than 2000 characters').optional().or(z.literal('')),
|
|
|
|
|
description: z.string().trim().max(2000, 'Description must be less than 2000 characters').nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
category: z.string().min(1, 'Category is required'),
|
|
|
|
|
ride_sub_type: z.string().trim().max(100, 'Sub type must be less than 100 characters').optional().or(z.literal('')),
|
|
|
|
|
ride_sub_type: z.string().trim().max(100, 'Sub type must be less than 100 characters').nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
status: z.enum(['operating', 'closed_permanently', 'closed_temporarily', 'under_construction', 'relocated', 'stored', 'demolished']),
|
|
|
|
|
park_id: z.string().uuid().optional().nullable(),
|
|
|
|
|
designer_id: z.string()
|
|
|
|
|
@@ -106,10 +108,10 @@ export const rideValidationSchema = z.object({
|
|
|
|
|
)
|
|
|
|
|
.optional()
|
|
|
|
|
.nullable(),
|
|
|
|
|
opening_date: z.string().optional().or(z.literal('')),
|
|
|
|
|
opening_date_precision: z.enum(['day', 'month', 'year']).optional(),
|
|
|
|
|
closing_date: z.string().optional().or(z.literal('')),
|
|
|
|
|
closing_date_precision: z.enum(['day', 'month', 'year']).optional(),
|
|
|
|
|
opening_date: z.string().nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
opening_date_precision: z.enum(['day', 'month', 'year']).nullable().optional(),
|
|
|
|
|
closing_date: z.string().nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
closing_date_precision: z.enum(['day', 'month', 'year']).nullable().optional(),
|
|
|
|
|
height_requirement: z.preprocess(
|
|
|
|
|
(val) => val === '' || val === null || val === undefined ? undefined : Number(val),
|
|
|
|
|
z.number().int().min(0, 'Height requirement must be positive').max(300, 'Height requirement must be less than 300cm').optional()
|
|
|
|
|
@@ -164,9 +166,9 @@ export const rideValidationSchema = z.object({
|
|
|
|
|
)
|
|
|
|
|
.optional()
|
|
|
|
|
.nullable(),
|
|
|
|
|
coaster_type: z.string().optional(),
|
|
|
|
|
seating_type: z.string().optional(),
|
|
|
|
|
intensity_level: z.string().optional(),
|
|
|
|
|
coaster_type: z.string().nullable().optional(),
|
|
|
|
|
seating_type: z.string().nullable().optional(),
|
|
|
|
|
intensity_level: z.string().nullable().optional(),
|
|
|
|
|
track_material: z.array(z.string()).optional().nullable(),
|
|
|
|
|
support_material: z.array(z.string()).optional().nullable(),
|
|
|
|
|
propulsion_method: z.array(z.string()).optional().nullable(),
|
|
|
|
|
@@ -179,15 +181,15 @@ export const rideValidationSchema = z.object({
|
|
|
|
|
(val) => val === '' || val === null || val === undefined ? undefined : Number(val),
|
|
|
|
|
z.number().min(0, 'Splash height must be positive').max(100, 'Splash height must be less than 100 meters').optional()
|
|
|
|
|
),
|
|
|
|
|
wetness_level: z.enum(['dry', 'light', 'moderate', 'soaked']).optional(),
|
|
|
|
|
flume_type: z.string().trim().max(100, 'Flume type must be less than 100 characters').optional().or(z.literal('')),
|
|
|
|
|
wetness_level: z.enum(['dry', 'light', 'moderate', 'soaked']).nullable().optional(),
|
|
|
|
|
flume_type: z.string().trim().max(100, 'Flume type must be less than 100 characters').nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
boat_capacity: z.preprocess(
|
|
|
|
|
(val) => val === '' || val === null || val === undefined ? undefined : Number(val),
|
|
|
|
|
z.number().int().min(1, 'Boat capacity must be positive').max(100, 'Boat capacity must be less than 100').optional()
|
|
|
|
|
),
|
|
|
|
|
// Dark ride specific fields
|
|
|
|
|
theme_name: z.string().trim().max(200, 'Theme name must be less than 200 characters').optional().or(z.literal('')),
|
|
|
|
|
story_description: z.string().trim().max(2000, 'Story description must be less than 2000 characters').optional().or(z.literal('')),
|
|
|
|
|
theme_name: z.string().trim().max(200, 'Theme name must be less than 200 characters').nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
story_description: z.string().trim().max(2000, 'Story description must be less than 2000 characters').nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
show_duration_seconds: z.preprocess(
|
|
|
|
|
(val) => val === '' || val === null || val === undefined ? undefined : Number(val),
|
|
|
|
|
z.number().int().min(0, 'Show duration must be positive').max(7200, 'Show duration must be less than 2 hours').optional()
|
|
|
|
|
@@ -196,15 +198,15 @@ export const rideValidationSchema = z.object({
|
|
|
|
|
(val) => val === '' || val === null || val === undefined ? undefined : Number(val),
|
|
|
|
|
z.number().int().min(0, 'Animatronics count must be positive').max(1000, 'Animatronics count must be less than 1000').optional()
|
|
|
|
|
),
|
|
|
|
|
projection_type: z.string().trim().max(100, 'Projection type must be less than 100 characters').optional().or(z.literal('')),
|
|
|
|
|
ride_system: z.string().trim().max(100, 'Ride system must be less than 100 characters').optional().or(z.literal('')),
|
|
|
|
|
projection_type: z.string().trim().max(100, 'Projection type must be less than 100 characters').nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
ride_system: z.string().trim().max(100, 'Ride system must be less than 100 characters').nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
scenes_count: z.preprocess(
|
|
|
|
|
(val) => val === '' || val === null || val === undefined ? undefined : Number(val),
|
|
|
|
|
z.number().int().min(0, 'Scenes count must be positive').max(100, 'Scenes count must be less than 100').optional()
|
|
|
|
|
),
|
|
|
|
|
// Flat ride specific fields
|
|
|
|
|
rotation_type: z.enum(['horizontal', 'vertical', 'multi_axis', 'pendulum', 'none']).optional(),
|
|
|
|
|
motion_pattern: z.string().trim().max(200, 'Motion pattern must be less than 200 characters').optional().or(z.literal('')),
|
|
|
|
|
rotation_type: z.enum(['horizontal', 'vertical', 'multi_axis', 'pendulum', 'none']).nullable().optional(),
|
|
|
|
|
motion_pattern: z.string().trim().max(200, 'Motion pattern must be less than 200 characters').nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
platform_count: z.preprocess(
|
|
|
|
|
(val) => val === '' || val === null || val === undefined ? undefined : Number(val),
|
|
|
|
|
z.number().int().min(1, 'Platform count must be positive').max(100, 'Platform count must be less than 100').optional()
|
|
|
|
|
@@ -234,10 +236,10 @@ export const rideValidationSchema = z.object({
|
|
|
|
|
(val) => val === '' || val === null || val === undefined ? undefined : Number(val),
|
|
|
|
|
z.number().int().min(0, 'Max age must be positive').max(18, 'Max age must be less than 18').optional()
|
|
|
|
|
),
|
|
|
|
|
educational_theme: z.string().trim().max(200, 'Educational theme must be less than 200 characters').optional().or(z.literal('')),
|
|
|
|
|
character_theme: z.string().trim().max(200, 'Character theme must be less than 200 characters').optional().or(z.literal('')),
|
|
|
|
|
educational_theme: z.string().trim().max(200, 'Educational theme must be less than 200 characters').nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
character_theme: z.string().trim().max(200, 'Character theme must be less than 200 characters').nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
// Transportation ride specific fields
|
|
|
|
|
transport_type: z.enum(['train', 'monorail', 'skylift', 'ferry', 'peoplemover', 'cable_car']).optional(),
|
|
|
|
|
transport_type: z.enum(['train', 'monorail', 'skylift', 'ferry', 'peoplemover', 'cable_car']).nullable().optional(),
|
|
|
|
|
route_length_meters: z.preprocess(
|
|
|
|
|
(val) => val === '' || val === null || val === undefined ? undefined : Number(val),
|
|
|
|
|
z.number().min(0, 'Route length must be positive').max(50000, 'Route length must be less than 50km').optional()
|
|
|
|
|
@@ -258,19 +260,21 @@ export const rideValidationSchema = z.object({
|
|
|
|
|
(val) => val === '' || val === null || val === undefined ? undefined : Number(val),
|
|
|
|
|
z.number().int().min(0, 'Round trip duration must be positive').max(7200, 'Round trip duration must be less than 2 hours').optional()
|
|
|
|
|
),
|
|
|
|
|
banner_image_id: z.string().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
banner_image_url: z.string().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
card_image_id: z.string().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
card_image_url: z.string().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
banner_image_id: z.string().nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
banner_image_url: z.string().nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
card_image_id: z.string().nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
card_image_url: z.string().nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
images: imageAssignmentSchema,
|
|
|
|
|
source_url: z.string().trim().optional().or(z.literal('')).refine((val) => {
|
|
|
|
|
source_url: z.string().trim().nullable().optional().or(z.literal('')).transform(val => val || undefined).refine((val) => {
|
|
|
|
|
if (!val || val === '') return true;
|
|
|
|
|
return z.string().url().safeParse(val).success;
|
|
|
|
|
}, 'Invalid URL format. Must be a valid URL starting with http:// or https://'),
|
|
|
|
|
submission_notes: z.string().trim()
|
|
|
|
|
.max(1000, 'Submission notes must be less than 1000 characters')
|
|
|
|
|
.nullable()
|
|
|
|
|
.optional()
|
|
|
|
|
.or(z.literal('')),
|
|
|
|
|
.or(z.literal(''))
|
|
|
|
|
.transform(val => val || undefined),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// ============================================
|
|
|
|
|
@@ -281,32 +285,34 @@ export const companyValidationSchema = z.object({
|
|
|
|
|
name: z.string().trim().min(1, 'Company name is required').max(200, 'Name must be less than 200 characters'),
|
|
|
|
|
slug: z.string().trim().min(1, 'Slug is required').regex(/^[a-z0-9-]+$/, 'Slug must contain only lowercase letters, numbers, and hyphens'),
|
|
|
|
|
company_type: z.enum(['manufacturer', 'designer', 'operator', 'property_owner']),
|
|
|
|
|
description: z.string().trim().max(2000, 'Description must be less than 2000 characters').optional().or(z.literal('')),
|
|
|
|
|
description: z.string().trim().max(2000, 'Description must be less than 2000 characters').nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
person_type: z.enum(['company', 'individual', 'firm', 'organization']),
|
|
|
|
|
founded_date: z.string().optional().or(z.literal('')),
|
|
|
|
|
founded_date_precision: z.enum(['day', 'month', 'year']).optional(),
|
|
|
|
|
founded_date: z.string().nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
founded_date_precision: z.enum(['day', 'month', 'year']).nullable().optional(),
|
|
|
|
|
founded_year: z.preprocess(
|
|
|
|
|
(val) => val === '' || val === null || val === undefined ? undefined : Number(val),
|
|
|
|
|
z.number().int().min(1800, 'Founded year must be after 1800').max(currentYear, `Founded year cannot be after ${currentYear}`).optional()
|
|
|
|
|
),
|
|
|
|
|
headquarters_location: z.string().trim().max(200, 'Location must be less than 200 characters').optional().or(z.literal('')),
|
|
|
|
|
website_url: z.string().trim().optional().or(z.literal('')).refine((val) => {
|
|
|
|
|
headquarters_location: z.string().trim().max(200, 'Location must be less than 200 characters').nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
website_url: z.string().trim().nullable().optional().or(z.literal('')).transform(val => val || undefined).refine((val) => {
|
|
|
|
|
if (!val || val === '') return true;
|
|
|
|
|
return z.string().url().safeParse(val).success;
|
|
|
|
|
}, 'Invalid URL format'),
|
|
|
|
|
banner_image_id: z.string().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
banner_image_url: z.string().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
card_image_id: z.string().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
card_image_url: z.string().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
banner_image_id: z.string().nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
banner_image_url: z.string().nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
card_image_id: z.string().nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
card_image_url: z.string().nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
images: imageAssignmentSchema,
|
|
|
|
|
source_url: z.string().trim().optional().or(z.literal('')).refine((val) => {
|
|
|
|
|
source_url: z.string().trim().nullable().optional().or(z.literal('')).transform(val => val || undefined).refine((val) => {
|
|
|
|
|
if (!val || val === '') return true;
|
|
|
|
|
return z.string().url().safeParse(val).success;
|
|
|
|
|
}, 'Invalid URL format. Must be a valid URL starting with http:// or https://'),
|
|
|
|
|
submission_notes: z.string().trim()
|
|
|
|
|
.max(1000, 'Submission notes must be less than 1000 characters')
|
|
|
|
|
.nullable()
|
|
|
|
|
.optional()
|
|
|
|
|
.or(z.literal('')),
|
|
|
|
|
.or(z.literal(''))
|
|
|
|
|
.transform(val => val || undefined),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// ============================================
|
|
|
|
|
@@ -318,21 +324,23 @@ export const rideModelValidationSchema = z.object({
|
|
|
|
|
slug: z.string().trim().min(1, 'Slug is required').regex(/^[a-z0-9-]+$/, 'Slug must contain only lowercase letters, numbers, and hyphens'),
|
|
|
|
|
category: z.string().min(1, 'Category is required'),
|
|
|
|
|
ride_type: z.string().trim().min(1, 'Ride type is required').max(100, 'Ride type must be less than 100 characters'),
|
|
|
|
|
description: z.string().trim().max(2000, 'Description must be less than 2000 characters').optional().or(z.literal('')),
|
|
|
|
|
description: z.string().trim().max(2000, 'Description must be less than 2000 characters').nullable().optional().or(z.literal('')).transform(val => val || undefined),
|
|
|
|
|
manufacturer_id: z.string()
|
|
|
|
|
.refine(
|
|
|
|
|
val => !val || val === '' || val.startsWith('temp-') || /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(val),
|
|
|
|
|
'Must be a valid UUID or temporary placeholder'
|
|
|
|
|
)
|
|
|
|
|
.optional(),
|
|
|
|
|
source_url: z.string().trim().optional().or(z.literal('')).refine((val) => {
|
|
|
|
|
source_url: z.string().trim().nullable().optional().or(z.literal('')).transform(val => val || undefined).refine((val) => {
|
|
|
|
|
if (!val || val === '') return true;
|
|
|
|
|
return z.string().url().safeParse(val).success;
|
|
|
|
|
}, 'Invalid URL format. Must be a valid URL starting with http:// or https://'),
|
|
|
|
|
submission_notes: z.string().trim()
|
|
|
|
|
.max(1000, 'Submission notes must be less than 1000 characters')
|
|
|
|
|
.nullable()
|
|
|
|
|
.optional()
|
|
|
|
|
.or(z.literal('')),
|
|
|
|
|
.or(z.literal(''))
|
|
|
|
|
.transform(val => val || undefined),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// ============================================
|
|
|
|
|
|