BeginCollectionItem and FluentValidation

123 Views Asked by At

Anyone know if it is possible to use FluentValidation with BeginCollectionItem which appends GUIDs to the field/property names? I was able to set up the validator:

RuleForEach(x => x.Insureds).SetValidator(new InsuredInfoValidator());

public class InsuredInfoValidator : AbstractValidator<InsuredInfo>
{
    public InsuredInfoValidator()
    {
        RuleFor(x => x.LastName).NotEmpty().WithMessage("Required");
    }
}

Insureds is my collection. The ModelState validates correctly, but the message does not get placed next to the invalid field: LastName.

0

There are 0 best solutions below