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

New Post: When Problem.

$
0
0

Hello,

I have the following:

      When(x => x.Mark == MarkType.Annex, () => {

          Custom(x => {

            HttpPostedFileBase file = x.Files.First();

            if (file.ContentLength > 20971520)
              new ValidationFailure("Files", "The maximum file size is 20 MB");
            return null;

          });

      });

When I submit the form the x.Files.First() gives an error ...

However, this should not even run because x.Mark is not Annex and the condition is false.

I debugged it and the condition is really false.

Any idea what is wrong?

Thank you,

Miguel


Viewing all articles
Browse latest Browse all 1917


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