Below is a simplified version of my problem.
I can not flatten the model. There is a List of \"children\" that I need to validate a birthday.
I can not seem
Building on the answer of @kristoffer-jalen it is now:
public class ParentValidator : AbstractValidator
{
public ParentValidator()
{
RuleFor(model => model.Name).NotEmpty();
//RuleFor(model => model.Children)
// .SetCollectionValidator(model => new ChildValidator(model))
RuleForEach(model => model.Children)
.SetValidator(model => new ChildValidator(model));
}
}
public class ChildValidator : AbstractValidator
{
public ChildValidator(Parent parent)
{
RuleFor(model => model.ChildProperty).NotEmpty();
RuleFor(model => model.Birthday).Must(birthday => parent.Birthday < birthday);
}
}
as SetCollectionValidator is deprecated.