import { z } from 'zod' const ACCEPTED_UPLOAD_TYPES = ['image/jpeg', 'image/png', 'application/pdf'] const MAX_SIZE_BYTES = 1 * 1024 * 1024 // 1MB const DocumentUploadSchema = z.object({ entityType_code: z.string().default('encounter'), ref_id: z.number(), upload_employee_id: z.number(), name: z.string({ required_error: 'Mohon isi', }), type_code: z.string({ required_error: 'Mohon isi', }), content: z.custom() .refine((f) => f, { message: 'File tidak boleh kosong' }) .refine((f) => !f || f instanceof File, { message: 'Harus berupa file yang valid' }) .refine((f) => !f || ACCEPTED_UPLOAD_TYPES.includes(f.type), { message: 'Format file harus JPG, PNG, atau PDF', }) .refine((f) => !f || f.size <= MAX_SIZE_BYTES, { message: 'Maksimal 1MB' }), }) type DocumentUploadFormData = z.infer export { DocumentUploadSchema } export type { DocumentUploadFormData }