using FluentValidation;
using CMSMicroservice.Protobuf.Protos.Category;
namespace CMSMicroservice.Protobuf.Validator.Category;

public class GetAllCategoryByFilterRequestValidator : AbstractValidator<GetAllCategoryByFilterRequest>
{
    public GetAllCategoryByFilterRequestValidator()
    {
    }
    public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
    {
        var result = await ValidateAsync(ValidationContext<GetAllCategoryByFilterRequest>.CreateWithOptions((GetAllCategoryByFilterRequest)model, x => x.IncludeProperties(propertyName)));
        if (result.IsValid)
            return Array.Empty<string>();
        return result.Errors.Select(e => e.ErrorMessage);
    };
}
