Quantcast
Channel: Fluent Validation for .NET
Viewing all articles
Browse latest Browse all 1917

New Post: Is it possible to associate an ID with a rule?

$
0
0

I have the need to validate a class based on multiple rules, and for each rule display an error message accordingly. Mutliple rules may be applied to same property. However, I do not want to hard code the message in .WithMessage() statement directly.

Now, I'm trying to find out if it's possible to associate an ID with a rule. One a rule is broken upon validation, I can grab the ID and display appropriate message. The ID will be something like "Rule1", "RuleYearMustBeAfter2000". Is this possible?

I have looked at ruleset feature which does not seem to solve my problem. With ruleset we know which rule is broken, however the user that calls the validation may not have knowledge of every possible ruleset in the validator.


Viewing all articles
Browse latest Browse all 1917

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>