| 1 | import { z } from '@chatapp/common'; |
| 2 | |
| 3 | export const createMessageBodySchema = z.object({ |
| 4 | body: z.string().min(1).max(2000), |
| 5 | }); |
| 6 | |
| 7 | export const createMessageSchema = createMessageBodySchema.extend({ |
| 8 | conversationId: z.string().uuid(), |
| 9 | }); |
| 10 | |
| 11 | export const listMessagesQuerySchema = z.object({ |
| 12 | limit: z |
| 13 | .preprocess( |
| 14 | (value) => (value === undefined ? undefined : Number(value)), |
| 15 | z.number().int().min(1).max(200), |
| 16 | ) |
| 17 | .optional(), |
| 18 | after: z.string().datetime().optional(), |
| 19 | }); |