DataAnnotationsValidator never de-registering events (AddDataAnnotationsValidation) (original) (raw)
Multiple ValidationMessages are generated for the same single validation.
DataAnnotationsValidator registering events by EditContextDataAnnotationsExtensions.AddDataAnnotationsValidation. If the DataAnnotationsValidator gets re-rendered, its registering same events again. It can be same EditContext though. Because its never deregistering, its registering multiple times, results in multiple ValidationMessages for the same validation.
(namespace is Microsoft.AspNetCore.Components.Forms)
minimal repro: https://github.com/rlyme/ValidationStackingRepro
- hit the "toggle visibility" button some times
- click submit
--> multiple validation messages "The Summary field is required." are displayed
ASP.NET Core version: 5.0