mirror of
https://github.com/documenso/documenso.git
synced 2025-11-14 08:42:12 +10:00
new form component added for document attachments with Zod validation and TRPC integration.
40 lines
949 B
TypeScript
40 lines
949 B
TypeScript
import { z } from 'zod';
|
|
|
|
import { AttachmentType } from '@documenso/prisma/generated/types';
|
|
|
|
export const ZGetDocumentAttachmentsSchema = z.object({
|
|
documentId: z.number(),
|
|
});
|
|
|
|
export const ZGetDocumentAttachmentsResponseSchema = z.array(
|
|
z.object({
|
|
id: z.string(),
|
|
label: z.string(),
|
|
url: z.string(),
|
|
type: z.nativeEnum(AttachmentType),
|
|
}),
|
|
);
|
|
|
|
export const ZSetDocumentAttachmentsSchema = z.object({
|
|
documentId: z.number(),
|
|
attachments: z.array(
|
|
z.object({
|
|
id: z.string(),
|
|
label: z.string().min(1, 'Label is required'),
|
|
url: z.string().url('Invalid URL'),
|
|
type: z.nativeEnum(AttachmentType),
|
|
}),
|
|
),
|
|
});
|
|
|
|
export type TSetDocumentAttachmentsSchema = z.infer<typeof ZSetDocumentAttachmentsSchema>;
|
|
|
|
export const ZSetDocumentAttachmentsResponseSchema = z.array(
|
|
z.object({
|
|
id: z.string(),
|
|
label: z.string(),
|
|
url: z.string(),
|
|
type: z.nativeEnum(AttachmentType),
|
|
}),
|
|
);
|