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

New Post: How do you validate a list of ints using fluent validation?

$
0
0
My model has:
 public List<int> WindowGlassItems { get; set; }
Model Validator has
RuleFor(x => x.WindowGlassItems).SetCollectionValidator(new WindowGlassItemsValidator());
  public class WindowGlassItemsValidator : AbstractValidator<int>
    {
        public WindowGlassItemsValidator()
        {
            RuleFor(x=>x).NotNull().NotEqual(0).WithMessage("GLASS REQ");
        }
    }
Im getting:

Property name could not be automatically determined for expression x => x. Please specify either a custom property name by calling 'WithName'.

Viewing all articles
Browse latest Browse all 1917

Trending Articles



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