import { z } from 'zod'
import type { Subspecialist } from '~/models/subspecialist'

const SubspecialistSchema = 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'),
  specialist_id: z
    .union([
      z.string({ required_error: 'Spesialis harus diisi' }),
      z.number({ required_error: 'Spesialis harus diisi' }),
    ])
    .optional()
    .nullable(),
})

type SubspecialistFormData = z.infer<typeof SubspecialistSchema> & Partial<Subspecialist>

export { SubspecialistSchema }
export type { SubspecialistFormData }
