Blazored / FluentValidation

A library for using FluentValidation with Blazor
https://blazored.github.io/FluentValidation/
MIT License
597 stars 86 forks source link

Moved event handler logic to its own class which can be disposed of properly. #192

Closed astynax777 closed 1 year ago

astynax777 commented 1 year ago

Since the event handlers were in static classes, this allowed the event to be subscribed to multiple times causing increasing duplications of error messages. I found the issue when I was using the TelerikWizard and would fire off form validation, move to another step, and move back to the form again and fire validation again. It would result in the same error messages piling up each time I left and returned. This is the fix for that.

astynax777 commented 1 year ago

Here is the bug:

astynax777 commented 1 year ago

When I tested with the DataAnnotationsValidator, everything seemed to work. I found the solution to this when looking at the DataAnnotationsValidator source. Therefore, I followed Microsoft's implementation found here in my fix:

EditContextDataAnnotationsExtensions.cs DataAnnotationsValidator.cs