DatePicker invalid value capture

When the input date is not a date, I need to capture the text that the user entered. How can I get done?

I found this (documented in the link) after asking but unsure if there is a better way:
https://stackoverflow.com/questions/77419655/in-a-datepicker-in-vaadin-flow-how-to-get-the-invalid-value