import { z } from 'zod'

const PersonAddressSchema = z.object({
  locationType_code: z.string({
    required_error: 'Mohon pilih jenis alamat',
  }),
  address: z.string({
    required_error: 'Mohon lengkapi alamat',
  }),
  province_code: z.string({
    required_error: 'Mohon pilih provinsi',
  }),
  regency_code: z.string({
    required_error: 'Mohon pilih kabupaten/kota',
  }),
  district_code: z.string({
    required_error: 'Mohon pilih kecamatan',
  }),
  village_code: z.string({
    required_error: 'Mohon pilih kelurahan',
  }),
  postalRegion_code: z.string({
    required_error: 'Mohon lengkapi kode pos',
  }),
  // .min(5, 'Kode pos harus berupa angka 5 digit')
  // .regex(/^\d+$/, 'Kode pos harus berupa angka 5 digit'),
  rt: z.string().optional(),
  rw: z.string().optional(),
})

type PersonAddressFormData = z.infer<typeof PersonAddressSchema>

export { PersonAddressSchema }
export type { PersonAddressFormData }
