As per the question, I have a date range picker with start
and end
dates as part of a mat-form-field
. I want to perform a custom validation (for example, to ensure the absolute difference between start
and end
is not longer than 15 days) and display a mat-error
inside the mat-form-field
informing the user about the issue.
I also want to have multiple such validators and error messages. The errors are set on the form group correctly, but they are not displayed since the form field does not identify those specific errors as part of the field's "invalidating" set of errors. I got it to work by doing a nasty workaround setting the matStartDateInvalid
or matEndDateInvalid
errors on the start or end input fields, but this just is not something I'm okay with.
Here's a stackblitz highlighting the issue: Stackblitz
How can I do this the right way?