namespace BackOffice.BFF.Application.UserRoleCQ.Commands.CreateNewUserRole; public class CreateNewUserRoleCommandValidator : AbstractValidator { public CreateNewUserRoleCommandValidator() { RuleFor(model => model.RoleId) .NotNull(); RuleFor(model => model.UserId) .NotNull(); } public Func>> ValidateValue => async (model, propertyName) => { var result = await ValidateAsync(ValidationContext.CreateWithOptions((CreateNewUserRoleCommand)model, x => x.IncludeProperties(propertyName))); if (result.IsValid) return Array.Empty(); return result.Errors.Select(e => e.ErrorMessage); }; }