feat(documents): zod validators for folder CRUD

createFolderSchema, renameFolderSchema, moveFolderSchema,
moveDocumentToFolderSchema. Names: 1–200 chars, non-whitespace.
parentId/folderId nullable to allow root.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-09 19:52:39 +02:00
parent 4ec0004867
commit 830ac39900
2 changed files with 70 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import { z } from 'zod';
const folderName = z
.string()
.min(1, 'Folder name is required')
.max(200, 'Folder name cannot exceed 200 characters')
.refine((s) => s.trim().length > 0, 'Folder name cannot be only whitespace');
export const createFolderSchema = z.object({
name: folderName,
parentId: z.string().nullable(),
});
export type CreateFolderInput = z.infer<typeof createFolderSchema>;
export const renameFolderSchema = z.object({
name: folderName,
});
export type RenameFolderInput = z.infer<typeof renameFolderSchema>;
export const moveFolderSchema = z.object({
parentId: z.string().nullable(),
});
export type MoveFolderInput = z.infer<typeof moveFolderSchema>;
export const moveDocumentToFolderSchema = z.object({
folderId: z.string().nullable(),
});
export type MoveDocumentToFolderInput = z.infer<typeof moveDocumentToFolderSchema>;