36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { z } from 'zod';
|
|
|
|
export const getCommentsSchema = z.object({
|
|
pagePath: z.string().min(1).max(500),
|
|
page: z.coerce.number().int().min(1).default(1),
|
|
});
|
|
|
|
export const postAnonymousCommentSchema = z.object({
|
|
pagePath: z.string().min(1).max(500),
|
|
authorName: z.string().min(1).max(100).trim(),
|
|
authorEmail: z.string().email().max(255).optional(),
|
|
body: z.string().min(10).max(5000).trim(),
|
|
// Honeypot — should be empty if submitted by a human
|
|
website: z.string().max(0).optional(),
|
|
});
|
|
|
|
export const postAuthenticatedCommentSchema = z.object({
|
|
pagePath: z.string().min(1).max(500),
|
|
body: z.string().min(10).max(5000).trim(),
|
|
});
|
|
|
|
export const oauthExchangeSchema = z.object({
|
|
code: z.string().min(1).max(512),
|
|
redirectUri: z.string().url().max(1000),
|
|
});
|
|
|
|
export const moderateCommentSchema = z.object({
|
|
action: z.enum(['approve', 'reject']),
|
|
});
|
|
|
|
export const moderationQuerySchema = z.object({
|
|
status: z.enum(['PENDING', 'APPROVED', 'REJECTED']).optional(),
|
|
page: z.coerce.number().int().min(1).default(1),
|
|
pageSize: z.coerce.number().int().min(1).max(100).default(20),
|
|
});
|