namespace CMSMicroservice.Application.ProductImagesCQ.Commands.CreateNewProductImages; public class CreateNewProductImagesCommandValidator : AbstractValidator { public CreateNewProductImagesCommandValidator() { RuleFor(model => model.Title) .NotEmpty(); RuleFor(model => model.ImagePath) .NotEmpty(); RuleFor(model => model.ImageThumbnailPath) .NotEmpty(); } public Func>> ValidateValue => async (model, propertyName) => { var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewProductImagesCommand)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); }; }