I need to validate my field according to radio button value. This is the my sample code for the issue my radio button values are 1st radio button -> values.type === "PO" 2nd radio button -> values.type === "PRE"
this is my validation class,
import * as Yup from "yup";
const POValidation = Yup.object().shape({
purchaseOrderNumber: Yup.object()
.required("This field is Required"),
amount: Yup.number()
.required("This field is Required")
.typeError("Amount is required"),
number: Yup.string()
.required("This field is Required"),
term: Yup.object()
.required("This field is Required")
});
export { POValidation };
When user select 1st radio button, values.type === "PO", amount field must be mandatory, When user select 2st radio button values.type === "PRE", term field must be mandatory. How I apply this conditions to my validation class? Thanks