import * as Yup from 'yup';

const FcrStandardSchema: Yup.ObjectSchema<{
  weight: number | string;
  fcr_number: number | string;
  mortality: number | string;
}> = Yup.object({
  weight: Yup.number().nullable().required('Bobot wajib diisi!'),
  fcr_number: Yup.number()
    .nullable()
    .typeError('FCR harus angka!')
    .required('FCR harus diisi!'),
  mortality: Yup.number().nullable().required('Mortalitas wajib diisi!'),
});

export const FcrFormSchema = Yup.object({
  name: Yup.string().required('Nama wajib diisi!'),
  fcrStandards: Yup.array()
    .of(FcrStandardSchema)
    .min(1, 'Minimal 1 FCR Standard diisi1')
    .required('FCR wajib diisi!'),
});

export const UpdateFcrFormSchema = FcrFormSchema;

export type FcrFormValues = Yup.InferType<typeof FcrFormSchema>;
