i have written one rule to check whether objects Id within list are not null or empty. But rule is not failing. Is any problem in here with my code ?
NOTE : Id's are of string type.
RuleFor(x => x.MyListOfObjects).Must(x => x.All(x => !string.IsNullOrWhiteSpace(x.Id)))
.WithMessage("The Id should not be empty or null.");
Any pointers or suggestions are welcomed.
I've written the possible example for your code. Looks like everything is ok for your statement if you use fluent validation in the such way (please notice that if one item is "" or null check is still applied):