Exemplo n.º 1
0
        public bool IsUserNameValidForNonExistingUser(string userName, out string errorMessage)
        {
            if (string.IsNullOrEmpty(userName))
            {
                errorMessage = UserNameCanNotBeEmptyErrorMessage;
                return(false);
            }
            if (userName.Length < 8)
            {
                errorMessage = UserNameHasToBeMinimum8CharactersErrorMessage;
                return(false);
            }
            Regex regex = new Regex("^[a-zA-Z0-9]*$");

            if (!regex.IsMatch(userName))
            {
                errorMessage = UserNameHasToAlphaNumericWithNoSpecialCharactersErrorMessage;
                return(false);
            }
            if (!AccountGateway.IsUsernameCreatable(WorkingDirectory, userName))
            {
                errorMessage = UserNameProbablyExistsErrorMessage;
                return(false);
            }
            errorMessage = string.Empty;
            return(true);
        }