title: angular 2: validate a input field with built in validators
body: <p>Angular 2 has some built in validators like <em>maxlength</em>, <em>minlength</em> and <em>pattern</em>. i have written this line of code:</p>
  
  <pre><code> &lt;input id="mobile" type="text" class="form-control" name="mobile"
     minlength="10"&gt;
  </code></pre>
  
  <p>If a user enters for example a 5-digit number and goes to the next input field an error should appear that says like 'The number you have typed is incorrect'. </p>
  
  <p>How to do that with Angular 2?</p>
  
  <p>In angular 1 is very easy like this</p>
  
  <pre><code>         &lt;p class="help-block" ng-if="editForm.mobile.$error.minlength"&gt;
  
            &lt;h3&gt;This field is required to be at least 10 characters.&lt;/h3&gt;
           &lt;/p&gt;
  </code></pre>