Created
January 7, 2018 19:07
-
-
Save uno-de-piera/d5b27cf21448240896c8344fc579637c to your computer and use it in GitHub Desktop.
Validar número teléfono Angular 5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {AbstractControl, ValidatorFn} from '@angular/forms'; | |
export function phoneValidator(phoneExp: RegExp): ValidatorFn { | |
return (control: AbstractControl): {[key: string]: any} => { | |
const phone = phoneExp.test(control.value); | |
return !phone ? {'phoneNumber': {value: control.value}} : null; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment