Created
February 10, 2011 18:46
-
-
Save davidalpert/821081 to your computer and use it in GitHub Desktop.
Chained RuleFor (useful when several RuleFor's share a common predicate)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When(x => x.Id != 0) | |
.Check(RuleFor(x => x.Age).GreaterThan(4)) | |
.Check(RuleFor(x => x.Discount).Equal(10m)) | |
.Unless(x => x.Id == 5); | |
Check(RuleFor(x => x.Age).GreaterThan(4)) | |
.Check(RuleFor(x => x.Discount).Equal(10m)) | |
.Unless(x => x.Id == 5); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RuleFor(x => x.Age).GreaterThan(4).When(x => x.Id != 0).Unless(x => x.Id == 5); | |
RuleFor(x => x.Discount).Equal(10m).When(x => x.Id != 0).Unless(x => x.Id == 5); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment