From c36a56e0a4aaf66191c2eedc3b7e6d9328f267f1 Mon Sep 17 00:00:00 2001 From: ddshi <8811906+ddshi@user.noreply.gitee.com> Date: Fri, 27 Feb 2026 15:58:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Zod=20repeat=5Finte?= =?UTF-8?q?rval=20=E9=AA=8C=E8=AF=81=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 repeat_interval schema 从 .positive() 改为 .min(1).optional().nullable() 解决传入 null 时验证失败的问题 Co-Authored-By: Claude Opus 4.6 --- src/routes/events.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/routes/events.ts b/src/routes/events.ts index ce4de35..e920f8a 100644 --- a/src/routes/events.ts +++ b/src/routes/events.ts @@ -47,7 +47,7 @@ const createEventSchema = z.object({ date: z.string().optional(), // Can be empty string for reminders is_lunar: z.boolean().default(false), repeat_type: z.enum(['daily', 'weekly', 'monthly', 'yearly', 'none']).default('none'), - repeat_interval: z.number().int().positive().optional().nullable(), // 自定义间隔(周数) + repeat_interval: z.number().int().min(1).optional().nullable(), // 自定义间隔(周数) next_reminder_date: z.string().optional().nullable(), // 下一次提醒日期 is_holiday: z.boolean().default(false), is_completed: z.boolean().default(false), @@ -189,6 +189,7 @@ router.put( } const data = updateEventSchema.parse(req.body); + console.log('[Update Event] Request body:', JSON.stringify(req.body)); // Build dynamic update query const updates: string[] = [];