namespace CMSMicroservice.Application.UserOrderCQ.Commands.CreateNewUserOrder; public class CreateNewUserOrderCommandValidator : AbstractValidator { public CreateNewUserOrderCommandValidator() { RuleFor(model => model.Price) .NotNull(); RuleFor(model => model.PackageId) .NotNull(); RuleFor(model => model.PaymentStatus) .NotNull(); RuleFor(model => model.UserId) .NotNull(); } public Func>> ValidateValue => async (model, propertyName) => { var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewUserOrderCommand)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); }; }