namespace CMSMicroservice.Application.ProductGalleriesCQ.Commands.CreateNewProductGalleries;
public class CreateNewProductGallerysCommandValidator : AbstractValidator<CreateNewProductGalleriesCommand>
{
    public CreateNewProductGallerysCommandValidator()
    {
        RuleFor(model => model.ProductImageId)
            .NotNull();
        RuleFor(model => model.ProductId)
            .NotNull();
    }
    public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
    {
        var result = await ValidateAsync(ValidationContext<CreateNewProductGalleriesCommand>.CreateWithOptions((CreateNewProductGalleriesCommand)model, x => x.IncludeProperties(propertyName)));
        if (result.IsValid)
            return Array.Empty<string>();
        return result.Errors.Select(e => e.ErrorMessage);
    };
}
