import { AbstractControl, Validators, ValidatorFn } from '@angular/forms';


import { isPresent } from '../../integer';

export const phone = (country: string): ValidatorFn => {
  return (control: AbstractControl): { [key: string]: boolean } => {
    if (isPresent(Validators.required(control))) return null;

    let v: string = control.value;

    return  /^[0-9]{10,}$/.test(v) ? null : {phone: true};
  };
};
