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

New Post: Breaking change in 4.0?

$
0
0
Hi,

As developers of Catel we also provide a FluentValidation extension. Now one of my workitems for today was to upgrade FluentValidation to 4.0, but then one of our unit tests failed.

After a bit of puzzling, it seems like this is no longer giving an error when the strings are null:
        RuleFor(model => model.PersonFirstName).Length(3, 20);
        RuleFor(model => model.PersonLastName).Length(3, 20);
Now I have to do it like this:
        RuleFor(model => model.PersonFirstName).NotNull().Length(3, 20);
        RuleFor(model => model.PersonLastName).NotNull().Length(3, 20);
But can you explain to my how a string, which is null, which has 0 or an undefined number of characters can succeed for a length test of a length between 3 and 20?

Viewing all articles
Browse latest Browse all 1917

Trending Articles



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