I'm trying to access the startDate value in endDate whether which one is higher but I'm getting undefined when I'm trying to access using context.parent.startDate
const validateSchema = Yup.object().shape({
startDate: Yup.date()
.default(() => new Date())
.typeError("Please Enter valid Date Format")
.required("Field is Mandatory"),
endDate: Yup.date()
.default(() => new Date())
.typeError("Please Enter valid Date Format")
.required("Field is Mandatory")
.test(
"start end date logic",
"End date should be higher than start date",
(value, context) => {
console.log(context.parent.startDate);
console.log(value.toString());
}
),
//.min(Yup.ref("startDate"), "Minimum Date"),
});
I'm trying to access the startDate value in endDate whether which one is higher but I'm getting undefined when I'm trying to access using context.parent.startDate