Fix: debug after reset
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
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().optional(),
|
||||
name: z.string({ required_error: 'Mohon isi', }),
|
||||
type_code: z.string({ required_error: 'Mohon isi', }),
|
||||
content: z.custom<File>()
|
||||
.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<typeof DocumentUploadSchema>
|
||||
|
||||
export { DocumentUploadSchema }
|
||||
export type { DocumentUploadFormData }
|
||||
Reference in New Issue
Block a user