gunndabad / govuk-frontend-aspnetcore

ASP.NET Core integration for GOV.UK Design system
MIT License
30 stars 8 forks source link

Name used for date input parse errors should be overridable #282

Open gunndabad opened 1 month ago

gunndabad commented 1 month ago

When date input parsing encounters an error it produces an error using ModelMetadata's DisplayName https://github.com/gunndabad/govuk-frontend-aspnetcore/blob/main/src/GovUk.Frontend.AspNetCore/ModelBinding/DateInputModelConverterModelBinder.cs#L100

This is problematic when the display name is something like 'Enter start date' as we get error messages like 'Enter start date must be a real date'.

There should be a way to override the name used for producing parse errors e.g.

[DateInputMetadata(Name = "Start date")]