title: Angular 2 (Reactive forms) Listing all validation rules (like pattern, minlength, maxlength) in a form control whether or not in an error object
body: <p>I am creating a component where I need to list all the validation rules of an input.</p>
  
  <p>home.component.html</p>
  
  <pre><code>&lt;input-validation&gt;
     &lt;input type="text" class="form-control" formControlName="name"&gt;
  &lt;/input-validation&gt;
  </code></pre>
  
  <p>home.component.ts</p>
  
  <pre><code>export class HomeComponent implements OnInit {
      public myForm: FormGroup;
  
      constructor(private _fb: FormBuilder) { }
  
      ngOnInit() {
          this.myForm = this._fb.group({
              name: ['', [ &lt;any&gt;Validators.minLength(5), &lt;any&gt;Validators.pattern('^[0-9]*$')]],
              address: this._fb.group({
                  street: ['', &lt;any&gt;Validators.required],
                  postcode: ['8000']
              })
          });
  
      }
  }
  </code></pre>
  
  <p>For template driven forms I am using</p>
  
  <blockquote>
    <p>_rawValidators</p>
  </blockquote>
  
  <p>property of <strong>FormControlName.</strong></p>
  
  <p>But I noticed that <strong>_rawValidators</strong> does always returns empty array for Reactive forms.</p>
  
  <p>As you can see in above example <strong>formControlName="name"</strong> has two validators here <strong>minlength</strong> and <strong>pattern</strong>. Now unless you starts writing in this input, the <em>errors</em> object of <strong>FormControl</strong> is null.</p>
  
  <p>So if anyone could help me to understand how ReactiveForms works(validates) or where it stores all its validators  would be much appreciable.</p>
  
  <p>Thanks</p>