Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow adding failures programmatically #243

Open
ramduq opened this issue Jan 7, 2025 · 0 comments
Open

Allow adding failures programmatically #243

ramduq opened this issue Jan 7, 2025 · 0 comments
Labels
Feature Request Request to add a new feature Triage Issue needs to be triaged

Comments

@ramduq
Copy link

ramduq commented Jan 7, 2025

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.

@ramduq ramduq added Feature Request Request to add a new feature Triage Issue needs to be triaged labels Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Request to add a new feature Triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

1 participant