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:
Mohamed ELIDRISSI
2022-12-30 18:49:01 +01:00
committed by GitHub
parent f3469d25fe
commit 318e1df13b
4 changed files with 67 additions and 90 deletions

View 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>;