Fluent Validation on a class, which is wrapper of class which has fluent validation

Hi,

I stuck with triggering validations on wrapper class, which is wrapper of list of class who has fluent validations.
following is my original RequestDto-

[Route("/ApplicationModuleGroup", "POST", Summary = "Create ApplicationModuleGroup")]
public class CreateLookUpRequestDto : IReturn<CreateLookUpRequestDtoResponse>
{
    [ApiMember(IsRequired = true)]
    public string Name { get; set; }

    public string Description { get; set; }

    [IgnoreDataMember]
    public bool Bulk { get; set; }
}

Here is it’s response object

public class CreateLookUpRequestDtoResponse : IHasResponseStatus
{
    public int Id { get; set; }
    public ResponseStatus ResponseStatus { get; set; }
}

For this request object, I have following fluent validator-

public class CreateLookUpValidator : AbstractValidator<CreateLookUpRequestDto>
{
    public CreateLookUpValidator()
    {
       RuleFor(r => r.Name).NotNull();
       RuleFor(r => r.Name).Length(1, 100);
       RuleFor(r => r.Description).Length(0, 2000);
    }
}

Now, I have created one more RequestObject which is wrapper of list of above request object (to support bulk WS)-

[Route("/ApplicationModuleGroupBulk", "POST", Summary = "Create bulk ApplicationModuleGroup")]
 public class CreateLookUpBulkRequestDto : List<CreateLookUpRequestDto>
 {

 }

And here is it’s response object-

public class CreateLookUpBulkRequestDtoResponse : List<CreateLookUpRequestDtoResponse>
{

}

But, this structure of classes doesn’t triggers validation for each object of ‘CreateLookUpRequestDto’ withing list from ‘CreateLookUpBulkRequestDto’. I have following validator present for bulk request-

public class CreateLookUpBulkValidator : AbstractValidator<CreateLookUpBulkRequestDto>
{
    public CreateLookUpBulkValidator()
    {           
       RuleFor(x => x.ForEach(y => RuleFor(y.Name).NotNull()));
    }
}

Can you suggest me LINQ to use existing validator of single RequestDto for list of RequestDtos ?

Thanks in Advance

Please refer to FluentValidation docs for validating collections, although it doesn’t show that you can validate Models that inherit a collection, so you may need to change your DTO to accept the collection as a property.