title: Angular forms custom validator null return not removing error from form
body: <p>So I've created a custom validator to verify that the confirm password input matches the original entry.  Works fine.  However, I'm allowing that both fields be blank since this is on a page where someone can change their password in their settings, which of course they may not want to do.  The form should become valid if both are blank so that it can be submitted and the other settings may be updated for their profile, but something weird is happening.</p>
  
  <p>Form props:</p>
  
  <pre><code>passControl = new FormControl('', [
    FormValidation.checkPasswordStrength()
  ]);
  
  passConfirmControl = new FormControl('', [
  ]);
  
  profileForm = new FormGroup(
    {
      password: this.passControl,
      passwordConfirm: this.passConfirmControl
    },
    {
      validators: FormValidation.checkPasswordsMatch()
    }
  );
  </code></pre>
  
  <p>Here's my validation function:</p>
  
  <pre><code>static checkPasswordsMatch(): ValidatorFn {
    return (control: AbstractControl): {[key: string]: any} =&gt; {
      let passwordCtrl = control.get('password');
      let passwordConfirmCtrl = control.get('passwordConfirm');
  
      // allow blank for when they don't want to change password
      if (passwordCtrl.value === '' &amp;&amp; passwordConfirmCtrl.value === '') {
        console.log('both are blank');
        return null;
      }
  
      if (passwordCtrl.value !== passwordConfirmCtrl.value) {
        console.log('hit mismatch passwords');
        control.get('passwordConfirm').setErrors( { passwordMatch: true } );
      }
  
      return null;
    };
  }
  </code></pre>
  
  <p>So when the form loads, its actually valid and I see <code>both are blank</code>.  However, if you touch the password field and type something, and of course it shows that now they don't match, but when you delete what you typed there, then the function shows that they are again both empty, but the error sticks and the form stays invalid, unless you also touch the passwordConfirm field and <strong>also type something and delete it</strong>.  What am I missing?</p>