Files
CapaKraken/packages/shared/src/schemas/country.schema.ts
T

38 lines
1.2 KiB
TypeScript

import { z } from "zod";
export const SpainScheduleRuleSchema = z.object({
type: z.literal("spain"),
fridayHours: z.number().positive(),
summerPeriod: z.object({
from: z.string().regex(/^\d{2}-\d{2}$/),
to: z.string().regex(/^\d{2}-\d{2}$/),
}),
summerHours: z.number().positive(),
regularHours: z.number().positive(),
});
export const CreateCountrySchema = z.object({
code: z.string().min(2).max(3).toUpperCase(),
name: z.string().min(1).max(100),
dailyWorkingHours: z.number().positive().max(24).default(8),
scheduleRules: SpainScheduleRuleSchema.nullable().optional(),
});
export const UpdateCountrySchema = CreateCountrySchema.partial().extend({
isActive: z.boolean().optional(),
});
export const CreateMetroCitySchema = z.object({
name: z.string().min(1).max(100),
countryId: z.string(),
});
export const UpdateMetroCitySchema = z.object({
name: z.string().min(1).max(100).optional(),
});
export type CreateCountryInput = z.infer<typeof CreateCountrySchema>;
export type UpdateCountryInput = z.infer<typeof UpdateCountrySchema>;
export type CreateMetroCityInput = z.infer<typeof CreateMetroCitySchema>;
export type UpdateMetroCityInput = z.infer<typeof UpdateMetroCitySchema>;