title: Angular 4 form validation on multiple fields
body: <p><strong>EDIT:</strong>
  What I want to achieve is a validation on one single formControl and not the whole form. The validator should check all atom fields like house number, street etc. and then invalidate the google maps input control.</p>
  
  <hr>
  
  <p>I am programming a form with Google Maps Autocomplete. 
  The user should enter a address into a input field that triggers the Google Maps autocomplete logic. When an address is selected the callback function selects the street, house number etc. and uses the API result to fill in the required address data fields.
  The other form elements are displayed but readonly so we always get valid data and can perform validation on the inputs. </p>
  
  <p>The problem is that my validator doesn't trigger the input field. The main input field is always valid and doesn't get the ng-invalid class. </p>
  
  <pre><code>@Component({
    selector: 'my-app',
  
    styles: [`
      .ng-valid {
        border:#0ff;
      }
  
      .ng-invalid {
        border:#f00;
      }
    `],
    template: `
  
    &lt;form [formGroup]="testForm"&gt;
                  &lt;input type="text" formControlName="address"&gt;
                  &lt;input type="text" formControlName="tel"&gt;
                  &lt;input type="text" formControlName="mail"&gt;
              &lt;/form&gt;
    `
  })
  export class AppComponent {
    testForm:FormGroup;
  
  
    constructor(private fb: FormBuilder) {
      this.testForm = this.fb.group({
              address:['', myValidator],
              tel:[''],
              mail:['']
          }, {
              validator: myValidator("tel", "mail")
          });
    }
  }
  
  export const myValidator = (field1, field2): ValidatorFn =&gt; (control: AbstractControl) =&gt; {
          if(control.get(field1).value=="test" &amp;&amp; control.get(field2).value=="test2") {
              return null;
          }
          return { myValidator: { valid: false } };
      }
  </code></pre>
  
  <p>I have made a punker of it so you can see it in action:
  <a href="https://plnkr.co/edit/2kncVT6thQTU1HMCmyTy?p=preview" rel="noreferrer">https://plnkr.co/edit/2kncVT6thQTU1HMCmyTy?p=preview</a></p>