Thursday, September 5, 2019

FluentValidation–Validating collections

On one of my projects we are using FluentValidation. After upgrading to FluentValidation 8 the way we had to validate our collections changed.

Before we were using this:

Now we had to use the RuleForEach method:

But what if you also want to validate if the collection itself is empty or not. This is still possible through RuleFor: