public CreateAssetCommandValidator(ICountryManager countryManager) { RuleFor(x => x.AssetName) .NotEmpty() .MinimumLength(5); RuleFor(x => x.Department) .Cascade(CascadeMode.Stop) .NotEmpty() .Must(x => Enum.IsDefined(typeof(Department), x)) .WithMessage("Department is not valid"); RuleFor(x => x.EMailAdressOfDepartment).EmailAddress(FluentValidation.Validators.EmailValidationMode.AspNetCoreCompatible); RuleFor(x => x.CountryOfDepartment) .MustAsync((x, cancellation) => countryManager.CountryIsValid(x)) .WithMessage("Country is not valid"); RuleFor(x => x.PurchaseDate).GreaterThan(x => DateTime.UtcNow.AddYears(-1)); }