yuyang041060120 / ng2-validation

angular2 validation
https://yuyang041060120.github.io/ng2-validation/index.html
MIT License
611 stars 213 forks source link

Phone validation multiple countries #99

Open vaduveerappan opened 7 years ago

vaduveerappan commented 7 years ago

Is it possible to allow multiple countries into phone validator?

These works individually : 1) new FormControl(null, Validators.compose([Validators.required, CustomValidators.phone('US')])), 2) new FormControl(null, Validators.compose([Validators.required, CustomValidators.phone('CA')])),

But when trying to do both ,"ERROR TypeError: Cannot read property '9' of undefined"

new FormControl(null, Validators.compose([Validators.required, CustomValidators.phone(['US','CA'])])),

Curious to know if there is multiple country support . If so how do we do?. Thank you

ghost commented 7 years ago

Added this feature, see my pull request.

You can use it like CustomValidators.phone('EN', 'US')