Check out example codes for "custom validator ERROR TypeError: "this.myForm.controls.cnfPass is undefined"". It will help you in understanding the concepts better.

Code Example 1

let _this = this
this.myForm = this.fb.group({
      'sku': ['', Validators.compose([Validators.required,this.skuValidator])],
      'question' : ['', Validators.required]
    });


 skuValidator(control: FormControl): { [s: string]: boolean } {
    if (!control.value.match(/^123/)) {
      alert('Inside skuValidator');
      console.log('value of this :: ' , _this);
      return {invalidSku: true};
    }
  }

Learn ReactJs, React Native from akashmittal.com