-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cbn): parsing phone number with language code
the language code should be replaced with country as soon as we figure out how to detect it
- Loading branch information
Marco Amadori
committed
Apr 3, 2020
1 parent
6deeb8b
commit 8bf3aee
Showing
7 changed files
with
24 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
10 changes: 10 additions & 0 deletions
10
interaction/lib/layout/src/lib/data-collection/custom-validators/phone-validator.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {AbstractControl, ValidatorFn} from '@angular/forms'; | ||
import {parsePhoneNumberFromString} from 'libphonenumber-js'; | ||
|
||
export function phoneNumberValidator(country): ValidatorFn { | ||
return (control: AbstractControl): {[key: string]: any} | null => { | ||
const phoneNumber = control.value; | ||
const phone = parsePhoneNumberFromString(phoneNumber, country.toUpperCase()); | ||
return (!phone || (phone && !phone.isValid())) ? { 'invalidPhoneNumber': { value: control.value }} : null; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...raction/lib/layout/src/lib/data-collection/data-collection/data-collection.component.html
This file contains 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
This file contains 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