Files
outline/server/routes/api/attachments/schema.ts
Mohamed ELIDRISSI 318e1df13b 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
2022-12-30 09:49:01 -08:00

29 lines
795 B
TypeScript

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