Closed khk1234 closed 5 months ago
The reason why Yup.date().typeError('invalidDate') doesn't catch invalid dates is that the RangeError is thrown when creating a Date object, which is before Yup's validation kicks in. This means that Yup's date() type doesn't have a chance to catch the error and this is more likely an issue of MUI v7
Describe the bug When i'm entering an invalid date like
12.02.YYYY
in an input field (I"m using @mui/x-date-pickers) It throws an error:The issue is that yup is not catching this error properly. When I define a Yup.date() schema with a typeError message like
Expected behavior The date type should catch RangeError exceptions thrown by date-fns v3 and convert them into a validation error.