title: How to pass parameters to custom validator function in angular reactive form?
body: <p>This is how i validate password, confirm password &amp; email, confirm email. As you can see i have a function fieldMatcher which is called to check for email and password validation.</p>
  
  <pre><code>// Works
  
  createForm() {
              this.formGroup = this._formBuilder.group({
                  firstName: '',
                  lastName: '',
                  email: '',
                  confirmEmail: '',
                  password: '',
                  confirmPassword: '',
              }, {validator: this.fieldMatcher});
          }
          fieldMatcher(c: AbstractControl): { invalid: boolean } {
              if (c.get('password').value !== c.get('confirm').value) {
                  return {invalid: true};
              }
              if (c.get('email').value !== c.get('confirmEmail').value) {
                  return {invalid: true};
              }
          }
      }
  </code></pre>
  
  <p>I would like to pass the controls to the fieldMatcher function as a parameters so that i reduce the code like below but that do not work,</p>
  
  <pre><code>// Do not Work
  createForm() {
          this.formGroup = this._formBuilder.group({
              firstName: '',
              lastName: '',
              email: '',
              confirmEmail: '',
              password: '',
              confirmPassword: '',
          },{validator: this.fieldMatcher(value1, value2)});
          }
          fieldMatcher(c: AbstractControl, value1, value2): { invalid: boolean } {
              if (c.get(value1).value !== c.get(value2).value) {
                  return {invalid: true};
              }
          }
  </code></pre>