namespace BackOffice.BFF.Application.OtpCQ.Commands.SendOtp; public class SendOtpCommandValidator : AbstractValidator { public SendOtpCommandValidator() { RuleFor(model => model.Mobile) .NotEmpty(); } public Func>> ValidateValue => async (model, propertyName) => { var result = await ValidateAsync(ValidationContext.CreateWithOptions((SendOtpCommand)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); }; }