public CommandValidator(IUserValidator validator) { RuleFor(c => c.UserName).NotNull().NotEmpty(); RuleFor(c => c.UserName) .MustAsync(validator.NameNotTakenAsync).WithMessage(ErrorMessages.USERNAME_ALREADY_TAKEN); RuleFor(c => c.FirstName).NotNull().NotEmpty(); RuleFor(c => c.Password).NotNull().NotEmpty(); RuleFor(c => c.ConfirmedPassword) .Must((command, confirmedPassword) => validator.PasswordMatchesConfirmation(command.Password, confirmedPassword)) .WithMessage(ErrorMessages.PASSWORDS_DONT_MATCH); }