import { z } from "zod"; const optionalText = (max: number, message: string) => z.string().trim().max(max, message).optional().default(""); export const roomUpdateSchema = z.object({ coverUrl: optionalText(512, "房间头像不能超过 512 个字符"), description: optionalText(512, "房间简介不能超过 512 个字符"), title: z.string().trim().min(1, "请输入房间名称").max(128, "房间名称不能超过 128 个字符"), visibleRegionId: z.coerce.number().int().min(0, "区域 ID 不正确").default(0) }); export const roomStatusSchema = z.object({ status: z.string().trim().refine((value) => value === "active" || value === "closed", "房间状态不正确") }); export type RoomUpdateForm = z.infer; export type RoomStatusForm = z.infer;