54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import { z } from 'zod'
|
|
|
|
const todoItemSchema = z.object({
|
|
id: z.string(),
|
|
content: z.string(),
|
|
completed: z.boolean(),
|
|
})
|
|
|
|
const dayTodoSchema = z.object({
|
|
date: z.string(),
|
|
items: z.array(todoItemSchema),
|
|
})
|
|
|
|
export const getTodoQuerySchema = z.object({
|
|
year: z.string().optional(),
|
|
month: z.string().optional(),
|
|
})
|
|
|
|
export const saveTodoSchema = z.object({
|
|
year: z.number().int().positive(),
|
|
month: z.number().int().min(1).max(12),
|
|
dayTodos: z.array(dayTodoSchema),
|
|
})
|
|
|
|
export const addTodoSchema = z.object({
|
|
year: z.number().int().positive(),
|
|
month: z.number().int().min(1).max(12),
|
|
date: z.string(),
|
|
content: z.string(),
|
|
})
|
|
|
|
export const toggleTodoSchema = z.object({
|
|
year: z.number().int().positive(),
|
|
month: z.number().int().min(1).max(12),
|
|
date: z.string(),
|
|
itemIndex: z.number().int().nonnegative(),
|
|
completed: z.boolean(),
|
|
})
|
|
|
|
export const updateTodoSchema = z.object({
|
|
year: z.number().int().positive(),
|
|
month: z.number().int().min(1).max(12),
|
|
date: z.string(),
|
|
itemIndex: z.number().int().nonnegative(),
|
|
content: z.string(),
|
|
})
|
|
|
|
export const deleteTodoSchema = z.object({
|
|
year: z.number().int().positive(),
|
|
month: z.number().int().min(1).max(12),
|
|
date: z.string(),
|
|
itemIndex: z.number().int().nonnegative(),
|
|
})
|