-
- Notifications
You must be signed in to change notification settings - Fork 93
Allow adding failures programmatically #243
Description
FluentValidationValidator does not allow adding failures to the failure collection. This is needed in the following scenario:
Scenario
Client is a Blazor web assembly app. Server is an API project. Both perform validations using fluent validation. Thus, an API request from the client might get a response containing a List<ValidationFailure>. If it were possible to add these (backend) failures to the current collection, the UI would be updated accordingly (e.g. coloring the related fields in red).
Proposed solution
A new method
AddFailures(Dictionary<FieldIdentifier, List<ValidationFailure> failures) ** Alternatives considered**
I considered extending the class FluentValidationValidator in my project. However LastValidationResult (the dictionary of failures) is an internal field, which prevents accessing it from external projects.
An alternative solution would be to make this field protected, making it possible to manipulate this collection in derived classes.