Esempio n. 1
0
        private void ValidatePassword(string password)
        {
            if (TextValidator.IsNullEmptyOrWhiteSpace(password))
            { // Password empty or not provided.
                throw new ValidationException("Password can't be empty!");
            }

            if (!TextValidator.ContainsLowerLetters(password) || !TextValidator.ContainsUpperLetters(password))
            { // Password doesn't contain both uppercase and lowercase letters.
                throw new ValidationException("Password must contain both uppercase and lowecase letters!");
            }

            if (!TextValidator.ContainsNumbers(password) && !TextValidator.ContainsSymbols(password))
            { // Pasword doesn't contain neither numbers nor symbols.
                throw new ValidationException("Password must contain at least one number or symbol!");
            }

            if (!TextValidator.ContainsBetweenXAndYCharacters(password, 8, 32))
            { // Password doesn't have between 8 and 32 characters length.
                throw new ValidationException("Password must contain between 8 and 32 characters!");
            }
        }