Question: running rulesets in sequence.
See original GitHub issueSystem Details
- FluentValidation version: 8.6.0
- Web Framework version: .NET Core 3.0 Web API
Issue Description
Hello everyone, I checked through the documentation multiple times and didn’t quite find an answer so i’m sorry if its something too obvious 😃 What I want to do is run the default rules, and only if all of them pass, run a specific ruleset. This is how my code looks like atm:
var result = await validator.ValidateAsync(request);
if (result.IsValid)
result = await validator.ValidateAsync(request, ruleSet: "DbChecks");
Was just wondering if this is really how I should go about it, or is there a better way to achieve this?
Edit: for more clarification I want to do something like this: https://stackoverflow.com/questions/21896249/conditionally-executing-rule-with-fluentvalidation-for-net But without having to duplicate code as suggested in the answer…
Or even like this: https://github.com/JeremySkinner/FluentValidation/issues/65 But with more than 1 rule, e.g. I want to check if a confirmPassword field equals the password field only if both confirmPassword and password fields aren’t empty.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Interesting, I’ve the same problem, someone knows?
No further feedback received; closing.