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

New Post: when condition not working as expected

$
0
0
The rule you've defined above will only execute if IsPreferredCustomer is true. What you want is something like this instead:
RuleFor(x =>x.Discount).GreaterThan(0).When(x => x.IsPreferedCustomer == true);
RuleFor(x =>x.Discount).LessThanOrEqualTo(0).When(x => x.IsPreferredCustomer == false);

Viewing all articles
Browse latest Browse all 1917

Trending Articles



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