title: Angular 5 multiple input validation
body: <p>I am trying to make a custom validation so  i have created the following directive:</p>
  
  <pre><code>import {Directive, Input} from '@angular/core';
  import {AbstractControl, NG_VALIDATORS, Validator} from '@angular/forms';
  @Directive({
      selector: '[appEqualValidator]',
      providers: [
          {provide: NG_VALIDATORS, useExisting: EqualValidatorDirective, multi: true}
      ]
  })
  export class EqualValidatorDirective implements Validator {
      @Input('inputOne')
      inputOne: string;
      @Input('inputTwo')
      inputTwo: string;
  
      constructor() {
      }
  
      validate(c: AbstractControl) {
  
          const value = c.value;
          if ((value == null || value === undefined || value === '') &amp;&amp; this.inputOne === this.inputTwo) {
              return {
                  equalTo: {condition: this.inputOne === this.inputTwo}
              };
          }
          return null;
      }
  }
  </code></pre>
  
  <p>Now I am trying to add this to my form however I am having some issues using the multiple inputs:</p>
  
  <pre><code> &lt;div class="form-group"&gt;
      &lt;label&gt;E-mail&lt;/label&gt;
      &lt;input type="email" class="form-control" placeholder="Indtast email" [(ngModel)]="model.email" name="email" [email]="true" required/&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
      &lt;label style="display: block"&gt;Gentag E-mail&lt;/label&gt;
      &lt;input type="email" class="form-control" placeholder="Gentag email" [(ngModel)]="model.emailRepeat" required [email]="true" 
  [appEqualValidator]="value" name="emailRepeat"/&gt;
      &lt;li *ngIf="!emailVerify"&gt;
          De to emails er ikke ens
      &lt;/li&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I am not sure how to use the directive within the form. and making sure i can get both inputs.</p>
  
  <p>I was hoping some of you could point me in the right direction.</p>