import { z } from 'zod'
import type { Specialist } from '~/models/specialist'

const SpecialistSchema = z.object({
  code: z.string({ required_error: 'Kode harus diisi' }).min(1, 'Kode minimum 1 karakter'),
  name: z.string({ required_error: 'Nama harus diisi' }).min(1, 'Nama minimum 1 karakter'),
  unit_id: z
    .union([z.string({ required_error: 'Unit harus diisi' }), z.number({ required_error: 'Unit harus diisi' })])
    .optional()
    .nullable(),
})

type SpecialistFormData = z.infer<typeof SpecialistSchema> & Partial<Specialist>

export { SpecialistSchema }
export type { SpecialistFormData }
