refactor: add server side validation schema for attachments (#4606)
* refactor: schema for attachments.create * refactor: schema for attachments.delete * refactor: remove deprecated "public" request param
This commit is contained in:
committed by
GitHub
parent
f3469d25fe
commit
318e1df13b
28
server/routes/api/attachments/schema.ts
Normal file
28
server/routes/api/attachments/schema.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { z } from "zod";
|
||||
import { AttachmentPreset } from "@shared/types";
|
||||
|
||||
export const AttachmentsCreateSchema = z.object({
|
||||
/** Attachment name */
|
||||
name: z.string(),
|
||||
|
||||
/** Id of the document to which the Attachment belongs */
|
||||
documentId: z.string().uuid().optional(),
|
||||
|
||||
/** File size of the Attachment */
|
||||
size: z.number(),
|
||||
|
||||
/** Content-Type of the Attachment */
|
||||
contentType: z.string().optional().default("application/octet-stream"),
|
||||
|
||||
/** Attachment type */
|
||||
preset: z.nativeEnum(AttachmentPreset),
|
||||
});
|
||||
|
||||
export type AttachmentCreateReq = z.infer<typeof AttachmentsCreateSchema>;
|
||||
|
||||
export const AttachmentDeleteSchema = z.object({
|
||||
/** Id of the attachment to be deleted */
|
||||
id: z.string().uuid(),
|
||||
});
|
||||
|
||||
export type AttachmentDeleteReq = z.infer<typeof AttachmentDeleteSchema>;
|
||||
Reference in New Issue
Block a user