42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
|
|
import { z } from 'zod';
|
||
|
|
|
||
|
|
export const createPortSchema = z.object({
|
||
|
|
name: z.string().min(1).max(200),
|
||
|
|
slug: z
|
||
|
|
.string()
|
||
|
|
.min(1)
|
||
|
|
.max(100)
|
||
|
|
.regex(/^[a-z0-9-]+$/, 'Slug must be lowercase alphanumeric with hyphens'),
|
||
|
|
logoUrl: z.string().url().optional(),
|
||
|
|
primaryColor: z
|
||
|
|
.string()
|
||
|
|
.regex(/^#[0-9a-fA-F]{6}$/)
|
||
|
|
.optional(),
|
||
|
|
defaultCurrency: z.string().length(3).default('USD'),
|
||
|
|
timezone: z.string().min(1).default('America/Anguilla'),
|
||
|
|
});
|
||
|
|
|
||
|
|
export type CreatePortInput = z.infer<typeof createPortSchema>;
|
||
|
|
|
||
|
|
export const updatePortSchema = z.object({
|
||
|
|
name: z.string().min(1).max(200).optional(),
|
||
|
|
slug: z
|
||
|
|
.string()
|
||
|
|
.min(1)
|
||
|
|
.max(100)
|
||
|
|
.regex(/^[a-z0-9-]+$/, 'Slug must be lowercase alphanumeric with hyphens')
|
||
|
|
.optional(),
|
||
|
|
logoUrl: z.string().url().nullable().optional(),
|
||
|
|
primaryColor: z
|
||
|
|
.string()
|
||
|
|
.regex(/^#[0-9a-fA-F]{6}$/)
|
||
|
|
.nullable()
|
||
|
|
.optional(),
|
||
|
|
defaultCurrency: z.string().length(3).optional(),
|
||
|
|
timezone: z.string().min(1).optional(),
|
||
|
|
isActive: z.boolean().optional(),
|
||
|
|
settings: z.record(z.string(), z.unknown()).optional(),
|
||
|
|
});
|
||
|
|
|
||
|
|
export type UpdatePortInput = z.infer<typeof updatePortSchema>;
|