How to use the ngx-validators.PhoneValidators.isValidRegionCode function in ngx-validators

To help you get started, we’ve selected a few ngx-validators examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Nightapes / ngx-validators / examples / src / app / reactive-forms / phone-validator / phone-validator.component.ts View on Github external
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { PhoneValidators } from 'ngx-validators';
import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-reactive-phone-validator',
  templateUrl: './phone-validator.component.html',
  styleUrls: ['./phone-validator.component.css']
})
export class ReactiveFormPhoneValidatorComponent implements OnInit {
  form: FormGroup;
  countryCode: FormControl = new FormControl('', Validators.compose([
    Validators.required,
    PhoneValidators.isValidRegionCode
  ]));
  possiblePhone: FormControl = new FormControl('', Validators.compose([
    Validators.required,
    PhoneValidators.isPossibleNumberWithReason('ZZ')
  ]));
  phone: FormControl = new FormControl('', Validators.compose([
    Validators.required,
    PhoneValidators.isPhoneNumber('ZZ')
  ]));


  constructor(protected _fb: FormBuilder) { }

  ngOnInit() {

    this.form = this._fb.group({