question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: running rulesets in sequence.

See original GitHub issue

System 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:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
derldalfor100commented, Dec 8, 2019

Interesting, I’ve the same problem, someone knows?

0reactions
JeremySkinnercommented, Apr 27, 2020

No further feedback received; closing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The ruleset list | Pega Academy
While ruleset validation governs rule development and import, the ruleset list, also known as the ruleset stack, governs rule execution at run time....
Read more >
Consider rule set execution sequence
A rule set contains a list of rules that you may run against a record. ... The rule sets defined at different levels...
Read more >
What is the QFT?
Developed by the Right Question Institute, the Question Formulation Technique, or QFT, is a structured method for generating and improving questions.
Read more >
The ruleset list | Pega Academy
The ruleset list indicates the rulesets that are available to the application for a given operator session. The ruleset list is available in...
Read more >
Question: Business Rules Order of Execution
I'd like to know if there's an order of execution that I can count on to the business rules shape? Is the Accepted...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found