title: Making A Password Key Validator And One Of The Output Should Show: Reports ALL The Rules That The Key Failed
body: <p>I am making a Password/Key Validator with a set of rules which must be met to validate the Password/Key.</p>
  
  <p>These rules are the following: - The key be at least 7 characters long, AND at most 20 characters long, AND - The key must not start with the special characters '#' or '', AND - The key must not have a space character anywhere, AND - The key must have at least one Upper case character and at least one Lower case character, AND - The key must not contain the user's name, AND - The key must contain either a '#' or a '', but not both.</p>
  
  <p>I have managed to get all the rules to work. There are two outputs that checks the key against the rules and either reports that the key is valid or reports ALL the rules that the key failed.</p>
  
  <p>On the output, I am unable to show/report ALL the rules that the key failed.</p>
  
  <p>The code I currently have is below. I am new to learning java so please understand.</p>
  
  <pre><code> * Asks user for key word and the name and then checks if it is a valid key word.
   */
  public void doCompletion(){
      String key = UI.askString("Key:   ");
      String name = UI.askString("Your name:   ");
      this.validateKeyCompletion(key, name);
  }
  
  /** COMPLETION
   * Report that the key is valid or report ALL the rules that the key failed.
   */
  public void validateKeyCompletion(String key, String name){
      /*# YOUR CODE HERE */
     int characterNumber = key.length();
     boolean hasUppercase;
     boolean hasLowercase;
     hasUppercase = !key.equals(key.toLowerCase());
     hasLowercase = !key.equals(key.toUpperCase());
     String specialChars = "(.*[ #  _  ].*)";
     if (characterNumber &lt; 7 || characterNumber &gt; 20){
      UI.println("Invalid: Key length must not be less than 7 or greater than 20");
     }
     else if (key.contains(" ")){
      UI.println("Invalid: Key cannot contain ' '");
     }
     else if(!hasUppercase)
     {
      UI.println("Invalid: Key must contain an uppercase character");
     }
     else if(!hasLowercase)
     {
      UI.println("Invalid: Key must contain a lowercase character");
     }
     else if(key.matches(name)){
      UI.println("Invalid: Key cannot contain Username");
     }
     else  if(!key.matches("^[^#_]+[#_]{1,1}[^#_]*")) {
      UI.println("Invalid: Key must contain either a '#' or a '_', but not both");
     }
     else {
      UI.println("Valid");
     }
  
  
  }
  </code></pre>