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

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