public CreateRequirementTypeCommandValidator(IRequirementTypeValidator requirementTypeValidator) { CascadeMode = CascadeMode.Stop; RuleFor(command => command) .MustAsync((command, token) => NotExistsARequirementTypeWithSameCode(command.Code, token)) .WithMessage("Requirement type with this code already exists!") .MustAsync((command, token) => NotExistsARequirementTypeWithSameTitle(command.Title, token)) .WithMessage("Requirement type with this title already exists!"); async Task <bool> NotExistsARequirementTypeWithSameCode(string code, CancellationToken token) => !await requirementTypeValidator.ExistsWithSameCodeAsync(code, token); async Task <bool> NotExistsARequirementTypeWithSameTitle(string title, CancellationToken token) => !await requirementTypeValidator.ExistsWithSameTitleAsync(title, token); }