resolvers
resolvers copied to clipboard
Yup validation schema on nested object presenting error (with ref to issue #63)
Hi. Had same issue as #63 and was resolved, but to only two levels deep of object. I have...
const NewPackSchema = yup.object().shape({
reference: yup.string().required("Reference is a required field"),
createdById: yup.string().required("Created by is required"),
requestDetail: yup.object().shape({
reference: yup.string().required("REQ Reference is a required field"),
applicantDetail: yup.object().shape({
fullName: yup.string().required("Fullname is a required field"),
}),
}),
});
and get error of
TypeError: Cannot read properties of undefined (reading 'message')
on ...
<TextField
label="Fullname"
{...register("requestDetail.applicantDetail.fullName")}
error={errors.requestDetail?.applicantDetail?.fullName ? true : false}
// also tried error={errors.requestDetail.applicantDetail?.fullName ? true : false}
/>;
... help would be appreciated, thanks.
please follow the issue template.