public CreatePersonValidator(IProcessQueries queryProcessor) { CascadeMode = CascadeMode.StopOnFirstFailure; RuleFor(p => p.DisplayName) // display name cannot be empty .NotEmpty() .WithMessage(ValidatePerson.FailedBecauseDisplayNameWasEmpty) ; RuleFor(p => p.UserName) // if username is present, validate that it is not attached to another person .Must(p => ValidateUser.NameMatchesNoEntity(p, queryProcessor)) .WithMessage(ValidateUser.FailedBecauseNameMatchedEntity, p => p.UserName) ; }