title: How to check duplicate formcontrol values exist in form arrays in reactive forms in angular5?
body: <p>I am building form array like</p>
  
  <pre><code>    this.myForm= this.fb.group({
    codes: this.fb.array([])
   })
  
   this.codes =   this.myForm.controls['newChargecodes']
  
    this.codes.push(this.fb.group({
       chargeCode: ['', [Validators.required]],
    })
  
  
    addRow () {
     this.codes.push(this.fb.group({
       chargeCode: ['', [Validators.required]],
    })
  
    }
  
    Html
  
    &lt;tr *ngFor="let code of myForm.get('codes').controls; let i = index;" 
                [formGroupName]="i"&gt;
                 &lt;td class="text-center"&gt;
                    &lt;input class="form-control input-text text-center" pInputText type="text" placeholder="{{columns['chargeCode']}}" id="chargeCode"
                      formControlName="chargeCode" name="chargeCode"&gt;
                  &lt;/td&gt;
                  &lt;td&gt;&lt; a (click)="addRow()"&gt;+&lt;/a&gt;&lt;/td&gt;
   &lt;/tr&gt;
  </code></pre>
  
  <p>I want duplicate code validation</p>
  
  <p>example like if user enter </p>
  
  <pre><code>chargecode[0]-A1, -&gt; true
   chargecode[1]-A2, -&gt; true
   chargecode[2]-A1-&gt; -&gt; false-&gt;
  </code></pre>
  
  <p>it shoulD show error duplicate charge code while user enter input</p>
  
  <p>Please help me how to write custom validation for form arrays in reactive forms</p>