fix: 修复 Zod repeat_interval 验证错误

将 repeat_interval schema 从 .positive() 改为 .min(1).optional().nullable()
解决传入 null 时验证失败的问题

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
ddshi 2026-02-27 15:58:26 +08:00
parent dd21c03e06
commit c36a56e0a4

View File

@ -47,7 +47,7 @@ const createEventSchema = z.object({
date: z.string().optional(), // Can be empty string for reminders date: z.string().optional(), // Can be empty string for reminders
is_lunar: z.boolean().default(false), is_lunar: z.boolean().default(false),
repeat_type: z.enum(['daily', 'weekly', 'monthly', 'yearly', 'none']).default('none'), 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(), // 下一次提醒日期 next_reminder_date: z.string().optional().nullable(), // 下一次提醒日期
is_holiday: z.boolean().default(false), is_holiday: z.boolean().default(false),
is_completed: z.boolean().default(false), is_completed: z.boolean().default(false),
@ -189,6 +189,7 @@ router.put(
} }
const data = updateEventSchema.parse(req.body); const data = updateEventSchema.parse(req.body);
console.log('[Update Event] Request body:', JSON.stringify(req.body));
// Build dynamic update query // Build dynamic update query
const updates: string[] = []; const updates: string[] = [];