New Post: when condition not working as expected
So your rule will only run when customer.IsPreferredCustomer is true, as specified in the when clause, but your test code sets it to false. Because of this, no rules will run and therefore the...
View ArticleNew Post: when condition not working as expected
I wanted to invoke the validator for all the values of customer.IsPreferedCustomer (true/false). If it is true then discount should be >0 if it is false then discount should not be >0
View ArticleNew Post: when condition not working as expected
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...
View ArticleNew Post: checking for multiple values in when condition
RuleFor(customer => customer.Forename).NotEmpty().When(customer => customer.Surname.Equals("FOO")); The above rule only checks if Surname = FOO, how can I write a rule where Surname in...
View ArticleNew Post: checking for multiple values in when condition
RuleFor(x => x.Forename).NotEmpty().When(x => new[] { "FOO", "BAR", "BAZ" }.Contains(x.Surename));
View ArticleNew Post: checking for multiple values in when condition
The solution Works. Is there a way to check to see if a property is one of the valid values. For .eg. I am able to use RuleFor(customer => customer.Surname).Matches("(Foo|Bar)") But is there a way...
View ArticleNew Post: Make nested object required when the rule is added for at least one...
Hi Jeremy, I've similar code, it works but tests doesn't work properly, cause, PropertyName and Member.Name doesn't match. For example PropertyName is "Phone.Number" and Member.Name is "Number" in...
View ArticleSource code checked in, #a2a861a3b834fd09bbe1eef8b8cc87168bde7b8f
Compatibility updates for new versions of .net Remove deprecated SetValidator method
View ArticleSource code checked in, #5fd7e1de82f60b63e262239bc45b65a5bedd9c10
Revert project file changes for now.
View ArticleSource code checked in, #7cc5bff8149f29934af8a76bdcdb1d8942889a1a
Remove broken reference
View ArticleCreated Unassigned: CascadeMode.StopOnFirstFailure seems to be ignored [7197]
I have a model to validate:```public class BarcodeSearchCriteria{ public string Barcode { get; set; } public BarcodeType BarcodeType { get; set; } // enum}```and a validator doing it:```public class...
View ArticleCommented Unassigned: CascadeMode.StopOnFirstFailure seems to be ignored [7197]
I have a model to validate:```public class BarcodeSearchCriteria{ public string Barcode { get; set; } public BarcodeType BarcodeType { get; set; } // enum}```and a validator doing it:```public class...
View ArticleClosed Unassigned: CascadeMode.StopOnFirstFailure seems to be ignored [7197]
I have a model to validate:```public class BarcodeSearchCriteria{ public string Barcode { get; set; } public BarcodeType BarcodeType { get; set; } // enum}```and a validator doing it:```public class...
View ArticleNew Post: ValidationResultHolder - Rule Dependency
Hi Guys, In my project I need to implement a conditional variable to a Rule. Imagine, Rule B can only run if the Rule A does not fail, How do you achieve it today? What I've done is, I created a class...
View ArticleCreated Unassigned: Nuget support for windows phone 8.1 (windows runtime) [7198]
Can you please add support for nuget installation for windows phone 8.1 (windows runtime)?
View ArticleNew Post: Add error to collection if items invalid
It would be useful to be able to add an error for a collection property if any of the items fail validation. Fantasy code below:RuleFor(x => x.Guests) .SetCollectionValidator(x => new...
View ArticleNew Post: Syntax error in documentation example (AbstractValidator.Custom)
? new ValidationFailure("More than 9 pets is not allowed.") should be ? new ValidationFailure("Pets", "More than 9 pets is not allowed.")
View ArticleCreated Unassigned: Customizing all the error message with error code [7199]
Hats off. It is a great framework. I used it lot of time in my project. For my new project i have to pass error code and and customize all the error message.For example i have to generate error code...
View Article