title: Custom Validation in Angular2 forms
body: <p>Following the example here : </p>
  
  <p><a href="https://angular.io/docs/ts/latest/guide/forms.html" rel="nofollow">https://angular.io/docs/ts/latest/guide/forms.html</a></p>
  
  <p>My form looks like:</p>
  
  <pre><code>&lt;input type="text" class="form-control" id="name"
                 required
                 [(ngModel)]="model.name" name="name"
                 #name="ngModel" &gt;
          &lt;div [hidden]="name.valid || name.pristine" 
               class="alert alert-danger"&gt;
  </code></pre>
  
  <p>I want to add some custom validation to this form. I did find some advise about using ngFormModel and FormBuilders and Validation class, however I believe these are outdated and no longer recommended</p>
  
  <p>( <a href="http://almerosteyn.com/2016/03/angular2-form-validation-component" rel="nofollow">http://almerosteyn.com/2016/03/angular2-form-validation-component</a>)</p>
  
  <p>My question then is how do I add custom validation.</p>
  
  <p>In angular 1.x I used to add functions to ngModel.$parsers and ngModel.$formatters pipeline. What is the equivalent in angular 2 ?</p>