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

New Post: SetCollectionValidator not firing error?

$
0
0

Hello,

After reading Jeremy's blog about FV3 Collection Validation I added the following rule:

  RuleFor(x => x.Files).SetCollectionValidator(new FileValidator()).WithMessage("ERROR");

Where x.Files is of type HttpPostedFilleBase[] And FileValidator is:

 public class FileValidator : AbstractValidator<HttpPostedFileBase>

    public FileValidator() {
      RuleFor(x => x).NotNull().WithMessage("The file is required");
    }

}

When x.Files has 3 items but all them null I do not get any error on the ModelState.

Why is that?

Thank You,

Miguel

Thank You,

Miguel


Viewing all articles
Browse latest Browse all 1917

Trending Articles



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