title: how to validate phone number using country list in ionic 2?
body: <p>My code is as shown below. </p>
  
  <p>Please can anyone explain to me how I can give a list of all countries and validate the phone number?</p>
  
  <pre><code>&lt;div formGroupName="country_phone"&gt;
        &lt;ion-item&gt;
          &lt;ion-label  color="primary"&gt;Country&lt;/ion-label&gt;
          &lt;ion-select formControlName="country" cancelText="Cancel" okText="OK"&gt;
            &lt;ion-option *ngFor="let item of countries" [value]="item" &gt;{{item.name}}&lt;/ion-option&gt;
          &lt;/ion-select&gt;
        &lt;/ion-item&gt;
        &lt;ion-item&gt;
          &lt;ion-input [textMask]="{mask: validations_form.value.country_phone.country.phone_mask}" placeholder="{{ validations_form.value.country_phone.country.sample_phone }}" type="text" formControlName="phone"&gt;&lt;/ion-input&gt;
        &lt;/ion-item&gt;
        &lt;div class="validation-errors"&gt;
          &lt;ng-container *ngFor="let validation of validation_messages.phone"&gt;
            &lt;div class="error-message" *ngIf="validations_form.get('country_phone').get('phone').hasError(validation.type) &amp;&amp; (validations_form.get('country_phone').get('phone').dirty || validations_form.get('country_phone').get('phone').touched)"&gt;
              {{ validation.message }}
        &lt;/div&gt;
  &lt;/ng-container&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>This is the TS file code:</p>
  
  <pre><code>'phone': [
        { type: 'required', message: 'Phone is required.' },
        { type: 'validCountryPhone', message: 'Phone incorrect for the country selected' }
      ],
  </code></pre>