title: Angular: Do validators remove and re-assign errors on value changes (when they run)?
body: <p>I have created the below custom group validator which checks if passwords match. It works great however there is something I do not know WHY IT WORKS.</p>
  <pre><code>export class CustomGroupValidators {
     static matchFields(field1: string, field2: string, errorKey: string): ValidatorFn {
        return (group: AbstractControl): ValidationErrors | null =&gt; {
           const firstField = group.get(field1);
           const secondField = group.get(field2);
  
           if (firstField?.value !== secondField?.value) {
              secondField?.setErrors({ mismatch: true });
              return { [errorKey]: true };
           } else {
              return null;
           }
        };
     };
  }
  </code></pre>
  <ul>
  <li>The validator also sets an error to the second field if the matchFields validator itself returns error so I can provide feedback to the user.</li>
  </ul>
  <p>As you can see I do not clear or reset any errors, however when first &amp; second fields match validation works right and second field is valid - as per my wish. Does this mean that whenever a validator runs (either on a field or a group), it clears all the errors and re-evaluates / re-attaches those needed? Otherwise why don't I encounter a bug where &quot;mismatch&quot; error is still true when prior value caused the error to be set but current value is good?</p>
  <p>Also I do not clearly understand under which events validators run in general. I know they run on value changes however are there any other circumstances under which they run in addition to that?</p>