You are seeing that error because you the RuleFor method is expecting a property to be specified. I have been unable to get CollectionValidators to work with primitive types like you have. Instead, I use a custom validation method with Must
like this.
The only problem I have with this approach is I am unable to avoid repeating the error message across the 2 validations. If you don't require it when the list is null, you can leave it out after the NotNull
call.
RuleFor(x => x.WindowGlassItems)
//Stop on first failure to avoid exception in method with null value
.Cascade(CascadeMode.StopOnFirstFailure)
.NotNull().WithMessage("GLASS REQ")
.Must(NotEqualZero).WithMessage("GLASS REQ");
private bool NotEqualZero(List<int> ints)
{
return ints.All(i => i != 0);
}