Summary
With MUI X v8, DatePicker now reports partially filled dates as null instead of as an invalid date object, as documented at https://mui.com/x/migration/migration-pickers-v7/#treat-partially-filled-date-as-null-in-onchange.
As far as I can tell, there's now no good way to distinguish between an empty DatePicker and a partially-filled one. If the date field is meant to be optional, then a UI cannot reject incomplete input while accepting an absent date.
Could partial input be reported via onError, either as invalidDate or some new error name?
Examples
Using the example at https://mui.com/x/react-date-pickers/validation/#show-the-error - deleting the year field causes the reported error to go away.
Motivation
Show a warning to a user who has tried to submit a form having only partially entered a date, in situations which otherwise allow the date to be omitted entirely.
Search keywords: partial date
Summary
With MUI X v8,
DatePickernow reports partially filled dates asnullinstead of as an invalid date object, as documented at https://mui.com/x/migration/migration-pickers-v7/#treat-partially-filled-date-as-null-in-onchange.As far as I can tell, there's now no good way to distinguish between an empty
DatePickerand a partially-filled one. If the date field is meant to be optional, then a UI cannot reject incomplete input while accepting an absent date.Could partial input be reported via
onError, either asinvalidDateor some new error name?Examples
Using the example at https://mui.com/x/react-date-pickers/validation/#show-the-error - deleting the year field causes the reported error to go away.
Motivation
Show a warning to a user who has tried to submit a form having only partially entered a date, in situations which otherwise allow the date to be omitted entirely.
Search keywords: partial date