import * as Yup from 'yup';

export const NonstockFormSchema = Yup.object({
  name: Yup.string().required('Nama wajib diisi!'),

  uomId: Yup.number().min(1, 'UOM wajib diisi!').required('UOM wajib diisi!'),
  uom: Yup.object({
    value: Yup.number().min(1).required(),
    label: Yup.string().required(),
  }).nullable(),

  supplierIds: Yup.array().of(Yup.number().min(0, 'Supplier wajib diisi!')),
  suppliers: Yup.array().of(
    Yup.object({
      value: Yup.number().min(0).required(),
      label: Yup.string().required(),
    })
  ),

  flags: Yup.boolean().default(false),
});

export const UpdateNonstockFormSchema = NonstockFormSchema;

export type NonstockFormValues = Yup.InferType<typeof NonstockFormSchema>;
