Initial commit
This commit is contained in:
53
api/modules/todo/schemas.ts
Normal file
53
api/modules/todo/schemas.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
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(),
|
||||
})
|
||||
Reference in New Issue
Block a user