libphonenumber-js 1.10.21 → 1.10.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -24
- package/build/PhoneNumber.js +54 -34
- package/build/PhoneNumber.js.map +1 -1
- package/build/PhoneNumber.test.js +7 -1
- package/build/PhoneNumber.test.js.map +1 -1
- package/build/PhoneNumberMatcher.js +2 -2
- package/build/PhoneNumberMatcher.js.map +1 -1
- package/build/findNumbers/Leniency.js +4 -4
- package/build/findNumbers/Leniency.js.map +1 -1
- package/build/findPhoneNumbersInText.js +16 -48
- package/build/findPhoneNumbersInText.js.map +1 -1
- package/build/findPhoneNumbersInText.test.js +238 -0
- package/build/findPhoneNumbersInText.test.js.map +1 -1
- package/build/format.js +174 -96
- package/build/format.js.map +1 -1
- package/build/format.test.js +81 -39
- package/build/format.test.js.map +1 -1
- package/build/{formatNumberForMobileDialing.js → formatPhoneNumberForMobileDialing.js} +9 -17
- package/build/formatPhoneNumberForMobileDialing.js.map +1 -0
- package/build/formatPhoneNumberForMobileDialing.test.js +15 -0
- package/build/formatPhoneNumberForMobileDialing.test.js.map +1 -0
- package/build/helpers/getNumberType.test.js.map +1 -1
- package/build/{isPossibleNumber_.js → isPossible.js} +14 -1
- package/build/isPossible.js.map +1 -0
- package/build/isPossible.test.js +117 -0
- package/build/isPossible.test.js.map +1 -0
- package/build/isPossiblePhoneNumber.js +4 -4
- package/build/isPossiblePhoneNumber.js.map +1 -1
- package/build/{validate_.js → isValid.js} +17 -9
- package/build/isValid.js.map +1 -0
- package/build/isValid.test.js +138 -0
- package/build/isValid.test.js.map +1 -0
- package/build/isValidPhoneNumber.js +4 -4
- package/build/isValidPhoneNumber.js.map +1 -1
- package/build/legacy/findNumbers.js +29 -0
- package/build/legacy/findNumbers.js.map +1 -0
- package/build/{findNumbers.test.js → legacy/findNumbers.test.js} +1 -1
- package/build/legacy/findNumbers.test.js.map +1 -0
- package/build/{findPhoneNumbers.js → legacy/findPhoneNumbers.js} +8 -6
- package/build/legacy/findPhoneNumbers.js.map +1 -0
- package/build/{findPhoneNumbers.test.js → legacy/findPhoneNumbers.test.js} +5 -5
- package/build/legacy/findPhoneNumbers.test.js.map +1 -0
- package/build/{findPhoneNumbers_.js → legacy/findPhoneNumbersInitialImplementation.js} +9 -9
- package/build/legacy/findPhoneNumbersInitialImplementation.js.map +1 -0
- package/build/legacy/format.js +128 -0
- package/build/legacy/format.js.map +1 -0
- package/build/legacy/format.test.js +284 -0
- package/build/legacy/format.test.js.map +1 -0
- package/build/{getNumberType.js → legacy/getNumberType.js} +11 -6
- package/build/legacy/getNumberType.js.map +1 -0
- package/build/{getNumberType.test.js → legacy/getNumberType.test.js} +2 -2
- package/build/legacy/getNumberType.test.js.map +1 -0
- package/build/{isPossibleNumber.js → legacy/isPossibleNumber.js} +8 -3
- package/build/legacy/isPossibleNumber.js.map +1 -0
- package/build/{isPossibleNumber.test.js → legacy/isPossibleNumber.test.js} +1 -1
- package/build/legacy/isPossibleNumber.test.js.map +1 -0
- package/build/{validate.js → legacy/isValidNumber.js} +9 -4
- package/build/legacy/isValidNumber.js.map +1 -0
- package/build/{validate.test.js → legacy/isValidNumber.test.js} +10 -7
- package/build/legacy/isValidNumber.test.js.map +1 -0
- package/build/legacy/isValidNumberForRegion.js +79 -0
- package/build/legacy/isValidNumberForRegion.js.map +1 -0
- package/build/{isValidNumberForRegion.test.js → legacy/isValidNumberForRegion.test.js} +1 -1
- package/build/legacy/isValidNumberForRegion.test.js.map +1 -0
- package/build/{isValidNumberForRegion_.js → legacy/isValidNumberForRegion_.js} +2 -2
- package/build/legacy/isValidNumberForRegion_.js.map +1 -0
- package/build/legacy/parse.js +22 -0
- package/build/legacy/parse.js.map +1 -0
- package/build/legacy/parse.test.js +568 -0
- package/build/legacy/parse.test.js.map +1 -0
- package/build/{searchNumbers.js → legacy/searchNumbers.js} +3 -3
- package/build/legacy/searchNumbers.js.map +1 -0
- package/build/{searchNumbers.test.js → legacy/searchNumbers.test.js} +1 -1
- package/build/legacy/searchNumbers.test.js.map +1 -0
- package/build/normalizeArguments.js +89 -0
- package/build/normalizeArguments.js.map +1 -0
- package/build/parse.js +358 -24
- package/build/parse.js.map +1 -1
- package/build/parse.test.js +28 -8
- package/build/parse.test.js.map +1 -1
- package/build/parsePhoneNumber.js +3 -80
- package/build/parsePhoneNumber.js.map +1 -1
- package/build/parsePhoneNumber.test.js +63 -113
- package/build/parsePhoneNumber.test.js.map +1 -1
- package/build/parsePhoneNumberWithError.js +22 -0
- package/build/parsePhoneNumberWithError.js.map +1 -0
- package/build/parsePhoneNumberWithError.test.js +142 -0
- package/build/parsePhoneNumberWithError.test.js.map +1 -0
- package/{es6/parsePhoneNumberFromString_.js → build/parsePhoneNumberWithError_.js} +16 -22
- package/build/parsePhoneNumberWithError_.js.map +1 -0
- package/build/parsePhoneNumber_.js +22 -4
- package/build/parsePhoneNumber_.js.map +1 -1
- package/build/searchPhoneNumbersInText.js +33 -5
- package/build/searchPhoneNumbersInText.js.map +1 -1
- package/build/searchPhoneNumbersInText.test.js +24 -0
- package/build/searchPhoneNumbersInText.test.js.map +1 -1
- package/build/validatePhoneNumberLength.js +4 -4
- package/build/validatePhoneNumberLength.js.map +1 -1
- package/bundle/libphonenumber-js.min.js +1 -1
- package/bundle/libphonenumber-js.min.js.map +1 -1
- package/bundle/libphonenumber-max.js +1 -1
- package/bundle/libphonenumber-max.js.map +1 -1
- package/bundle/libphonenumber-min.js +1 -1
- package/bundle/libphonenumber-min.js.map +1 -1
- package/bundle/libphonenumber-mobile.js +1 -1
- package/bundle/libphonenumber-mobile.js.map +1 -1
- package/core/index.cjs +5 -4
- package/core/index.cjs.js +5 -4
- package/core/index.js +4 -5
- package/custom.js +17 -18
- package/es6/PhoneNumber.js +50 -28
- package/es6/PhoneNumber.js.map +1 -1
- package/es6/PhoneNumber.test.js +7 -1
- package/es6/PhoneNumber.test.js.map +1 -1
- package/es6/PhoneNumberMatcher.js +1 -1
- package/es6/PhoneNumberMatcher.js.map +1 -1
- package/es6/findNumbers/Leniency.js +1 -1
- package/es6/findNumbers/Leniency.js.map +1 -1
- package/es6/findPhoneNumbersInText.js +17 -47
- package/es6/findPhoneNumbersInText.js.map +1 -1
- package/es6/findPhoneNumbersInText.test.js +238 -0
- package/es6/findPhoneNumbersInText.test.js.map +1 -1
- package/es6/format.js +170 -96
- package/es6/format.js.map +1 -1
- package/es6/format.test.js +82 -41
- package/es6/format.test.js.map +1 -1
- package/es6/{formatNumberForMobileDialing.js → formatPhoneNumberForMobileDialing.js} +4 -12
- package/es6/formatPhoneNumberForMobileDialing.js.map +1 -0
- package/es6/formatPhoneNumberForMobileDialing.test.js +14 -0
- package/es6/formatPhoneNumberForMobileDialing.test.js.map +1 -0
- package/es6/helpers/getNumberType.test.js.map +1 -1
- package/es6/{isPossibleNumber_.js → isPossible.js} +15 -1
- package/es6/isPossible.js.map +1 -0
- package/es6/isPossible.test.js +111 -0
- package/es6/isPossible.test.js.map +1 -0
- package/es6/isPossiblePhoneNumber.js +3 -3
- package/es6/isPossiblePhoneNumber.js.map +1 -1
- package/es6/{validate_.js → isValid.js} +17 -9
- package/es6/isValid.js.map +1 -0
- package/es6/isValid.test.js +132 -0
- package/es6/isValid.test.js.map +1 -0
- package/es6/isValidPhoneNumber.js +3 -3
- package/es6/isValidPhoneNumber.js.map +1 -1
- package/es6/legacy/findNumbers.js +18 -0
- package/es6/legacy/findNumbers.js.map +1 -0
- package/es6/{findNumbers.test.js → legacy/findNumbers.test.js} +1 -1
- package/es6/legacy/findNumbers.test.js.map +1 -0
- package/es6/{findPhoneNumbers.js → legacy/findPhoneNumbers.js} +2 -2
- package/es6/legacy/findPhoneNumbers.js.map +1 -0
- package/es6/{findPhoneNumbers.test.js → legacy/findPhoneNumbers.test.js} +2 -2
- package/es6/legacy/findPhoneNumbers.test.js.map +1 -0
- package/es6/{findPhoneNumbers_.js → legacy/findPhoneNumbersInitialImplementation.js} +8 -8
- package/es6/legacy/findPhoneNumbersInitialImplementation.js.map +1 -0
- package/es6/legacy/format.js +116 -0
- package/es6/legacy/format.js.map +1 -0
- package/es6/legacy/format.test.js +279 -0
- package/es6/legacy/format.test.js.map +1 -0
- package/es6/{getNumberType.js → legacy/getNumberType.js} +9 -4
- package/es6/legacy/getNumberType.js.map +1 -0
- package/es6/{getNumberType.test.js → legacy/getNumberType.test.js} +2 -2
- package/es6/legacy/getNumberType.test.js.map +1 -0
- package/es6/{isPossibleNumber.js → legacy/isPossibleNumber.js} +7 -2
- package/es6/legacy/isPossibleNumber.js.map +1 -0
- package/es6/{isPossibleNumber.test.js → legacy/isPossibleNumber.test.js} +1 -1
- package/es6/legacy/isPossibleNumber.test.js.map +1 -0
- package/es6/{validate.js → legacy/isValidNumber.js} +8 -3
- package/es6/legacy/isValidNumber.js.map +1 -0
- package/es6/{validate.test.js → legacy/isValidNumber.test.js} +8 -5
- package/es6/legacy/isValidNumber.test.js.map +1 -0
- package/es6/legacy/isValidNumberForRegion.js +67 -0
- package/es6/legacy/isValidNumberForRegion.js.map +1 -0
- package/es6/{isValidNumberForRegion.test.js → legacy/isValidNumberForRegion.test.js} +1 -1
- package/es6/legacy/isValidNumberForRegion.test.js.map +1 -0
- package/es6/{isValidNumberForRegion_.js → legacy/isValidNumberForRegion_.js} +1 -1
- package/es6/legacy/isValidNumberForRegion_.js.map +1 -0
- package/es6/legacy/parse.js +11 -0
- package/es6/legacy/parse.js.map +1 -0
- package/es6/legacy/parse.test.js +562 -0
- package/es6/legacy/parse.test.js.map +1 -0
- package/es6/{searchNumbers.js → legacy/searchNumbers.js} +2 -2
- package/es6/legacy/searchNumbers.js.map +1 -0
- package/es6/{searchNumbers.test.js → legacy/searchNumbers.test.js} +1 -1
- package/es6/legacy/searchNumbers.test.js.map +1 -0
- package/es6/normalizeArguments.js +81 -0
- package/es6/normalizeArguments.js.map +1 -0
- package/es6/parse.js +336 -22
- package/es6/parse.js.map +1 -1
- package/es6/parse.test.js +28 -8
- package/es6/parse.test.js.map +1 -1
- package/es6/parsePhoneNumber.js +1 -76
- package/es6/parsePhoneNumber.js.map +1 -1
- package/es6/parsePhoneNumber.test.js +63 -112
- package/es6/parsePhoneNumber.test.js.map +1 -1
- package/es6/parsePhoneNumberWithError.js +11 -0
- package/es6/parsePhoneNumberWithError.js.map +1 -0
- package/es6/parsePhoneNumberWithError.test.js +136 -0
- package/es6/parsePhoneNumberWithError.test.js.map +1 -0
- package/{build/parsePhoneNumberFromString_.js → es6/parsePhoneNumberWithError_.js} +6 -34
- package/es6/parsePhoneNumberWithError_.js.map +1 -0
- package/es6/parsePhoneNumber_.js +20 -4
- package/es6/parsePhoneNumber_.js.map +1 -1
- package/es6/searchPhoneNumbersInText.js +33 -5
- package/es6/searchPhoneNumbersInText.js.map +1 -1
- package/es6/searchPhoneNumbersInText.test.js +24 -0
- package/es6/searchPhoneNumbersInText.test.js.map +1 -1
- package/es6/validatePhoneNumberLength.js +3 -3
- package/es6/validatePhoneNumberLength.js.map +1 -1
- package/index.cjs +9 -9
- package/index.cjs.js +9 -9
- package/index.es6.exports/PhoneNumberSearch.js +1 -1
- package/index.es6.exports/findPhoneNumbers.js +1 -1
- package/index.es6.exports/format.js +1 -1
- package/index.es6.exports/getNumberType.js +1 -1
- package/index.es6.exports/isPossibleNumber.js +1 -1
- package/index.es6.exports/isValidNumber.js +1 -1
- package/index.es6.exports/isValidNumberForRegion.js +1 -1
- package/index.es6.exports/parse.js +1 -1
- package/index.es6.exports/searchPhoneNumbers.js +1 -1
- package/index.js +8 -9
- package/max/exports/parsePhoneNumber.js +6 -0
- package/max/index.js +1 -2
- package/metadata.full.json +1 -1
- package/metadata.full.json.js +1 -1
- package/metadata.max.json +1 -1
- package/metadata.max.json.js +1 -1
- package/metadata.min.json +1 -1
- package/metadata.min.json.js +1 -1
- package/metadata.mobile.json +1 -1
- package/metadata.mobile.json.js +1 -1
- package/min/exports/parsePhoneNumber.js +6 -0
- package/min/index.js +1 -2
- package/mobile/exports/parsePhoneNumber.js +6 -0
- package/mobile/index.js +1 -2
- package/package.json +1 -1
- package/source/PhoneNumber.js +52 -26
- package/source/PhoneNumber.test.js +8 -0
- package/source/PhoneNumberMatcher.js +1 -1
- package/source/findNumbers/Leniency.js +1 -1
- package/source/findPhoneNumbersInText.js +10 -43
- package/source/findPhoneNumbersInText.test.js +220 -0
- package/source/format.js +167 -94
- package/source/format.test.js +54 -29
- package/source/{formatNumberForMobileDialing.js → formatPhoneNumberForMobileDialing.js} +3 -15
- package/source/formatPhoneNumberForMobileDialing.test.js +16 -0
- package/source/helpers/getNumberType.test.js +0 -1
- package/source/{isPossibleNumber_.js → isPossible.js} +13 -0
- package/source/isPossible.test.js +66 -0
- package/source/isPossiblePhoneNumber.js +3 -3
- package/source/{validate_.js → isValid.js} +16 -10
- package/source/isValid.test.js +116 -0
- package/source/isValidPhoneNumber.js +3 -3
- package/source/legacy/findNumbers.js +12 -0
- package/source/{findNumbers.test.js → legacy/findNumbers.test.js} +2 -2
- package/source/{findPhoneNumbers.js → legacy/findPhoneNumbers.js} +2 -2
- package/source/{findPhoneNumbers.test.js → legacy/findPhoneNumbers.test.js} +2 -2
- package/source/{findPhoneNumbers_.js → legacy/findPhoneNumbersInitialImplementation.js} +7 -7
- package/source/legacy/format.js +110 -0
- package/source/legacy/format.test.js +240 -0
- package/source/{getNumberType.js → legacy/getNumberType.js} +8 -5
- package/source/{getNumberType.test.js → legacy/getNumberType.test.js} +2 -2
- package/source/{isPossibleNumber.js → legacy/isPossibleNumber.js} +6 -3
- package/source/{isPossibleNumber.test.js → legacy/isPossibleNumber.test.js} +1 -1
- package/source/{validate.js → legacy/isValidNumber.js} +6 -3
- package/source/{validate.test.js → legacy/isValidNumber.test.js} +8 -3
- package/source/legacy/isValidNumberForRegion.js +62 -0
- package/source/{isValidNumberForRegion.test.js → legacy/isValidNumberForRegion.test.js} +1 -1
- package/source/{isValidNumberForRegion_.js → legacy/isValidNumberForRegion_.js} +1 -1
- package/source/legacy/parse.js +7 -0
- package/source/legacy/parse.test.js +524 -0
- package/source/{searchNumbers.js → legacy/searchNumbers.js} +2 -2
- package/source/{searchNumbers.test.js → legacy/searchNumbers.test.js} +1 -1
- package/source/normalizeArguments.js +57 -0
- package/source/parse.js +344 -22
- package/source/parse.test.js +19 -4
- package/source/parsePhoneNumber.js +1 -55
- package/source/parsePhoneNumber.test.js +53 -85
- package/source/parsePhoneNumberWithError.js +7 -0
- package/source/parsePhoneNumberWithError.test.js +112 -0
- package/source/parsePhoneNumberWithError_.js +5 -0
- package/source/parsePhoneNumber_.js +22 -3
- package/source/searchPhoneNumbersInText.js +22 -5
- package/source/searchPhoneNumbersInText.test.js +24 -0
- package/source/validatePhoneNumberLength.js +3 -3
- package/types.d.ts +12 -0
- package/build/findNumbers.js +0 -22
- package/build/findNumbers.js.map +0 -1
- package/build/findNumbers.test.js.map +0 -1
- package/build/findNumbers_.js +0 -22
- package/build/findNumbers_.js.map +0 -1
- package/build/findPhoneNumbers.js.map +0 -1
- package/build/findPhoneNumbers.test.js.map +0 -1
- package/build/findPhoneNumbers_.js.map +0 -1
- package/build/formatNumberForMobileDialing.js.map +0 -1
- package/build/formatNumberForMobileDialing.test.js +0 -15
- package/build/formatNumberForMobileDialing.test.js.map +0 -1
- package/build/format_.js +0 -203
- package/build/format_.js.map +0 -1
- package/build/getNumberType.js.map +0 -1
- package/build/getNumberType.test.js.map +0 -1
- package/build/isPossibleNumber.js.map +0 -1
- package/build/isPossibleNumber.test.js.map +0 -1
- package/build/isPossibleNumber_.js.map +0 -1
- package/build/isValidNumberForRegion.js +0 -42
- package/build/isValidNumberForRegion.js.map +0 -1
- package/build/isValidNumberForRegion.test.js.map +0 -1
- package/build/isValidNumberForRegion_.js.map +0 -1
- package/build/parsePhoneNumberFromString.js +0 -22
- package/build/parsePhoneNumberFromString.js.map +0 -1
- package/build/parsePhoneNumberFromString.test.js +0 -92
- package/build/parsePhoneNumberFromString.test.js.map +0 -1
- package/build/parsePhoneNumberFromString_.js.map +0 -1
- package/build/parse_.js +0 -371
- package/build/parse_.js.map +0 -1
- package/build/searchNumbers.js.map +0 -1
- package/build/searchNumbers.test.js.map +0 -1
- package/build/validate.js.map +0 -1
- package/build/validate.test.js.map +0 -1
- package/build/validate_.js.map +0 -1
- package/es6/findNumbers.js +0 -11
- package/es6/findNumbers.js.map +0 -1
- package/es6/findNumbers.test.js.map +0 -1
- package/es6/findNumbers_.js +0 -12
- package/es6/findNumbers_.js.map +0 -1
- package/es6/findPhoneNumbers.js.map +0 -1
- package/es6/findPhoneNumbers.test.js.map +0 -1
- package/es6/findPhoneNumbers_.js.map +0 -1
- package/es6/formatNumberForMobileDialing.js.map +0 -1
- package/es6/formatNumberForMobileDialing.test.js +0 -14
- package/es6/formatNumberForMobileDialing.test.js.map +0 -1
- package/es6/format_.js +0 -187
- package/es6/format_.js.map +0 -1
- package/es6/getNumberType.js.map +0 -1
- package/es6/getNumberType.test.js.map +0 -1
- package/es6/isPossibleNumber.js.map +0 -1
- package/es6/isPossibleNumber.test.js.map +0 -1
- package/es6/isPossibleNumber_.js.map +0 -1
- package/es6/isValidNumberForRegion.js +0 -30
- package/es6/isValidNumberForRegion.js.map +0 -1
- package/es6/isValidNumberForRegion.test.js.map +0 -1
- package/es6/isValidNumberForRegion_.js.map +0 -1
- package/es6/parsePhoneNumberFromString.js +0 -11
- package/es6/parsePhoneNumberFromString.js.map +0 -1
- package/es6/parsePhoneNumberFromString.test.js +0 -87
- package/es6/parsePhoneNumberFromString.test.js.map +0 -1
- package/es6/parsePhoneNumberFromString_.js.map +0 -1
- package/es6/parse_.js +0 -339
- package/es6/parse_.js.map +0 -1
- package/es6/searchNumbers.js.map +0 -1
- package/es6/searchNumbers.test.js.map +0 -1
- package/es6/validate.js.map +0 -1
- package/es6/validate.test.js.map +0 -1
- package/es6/validate_.js.map +0 -1
- package/max/exports/parsePhoneNumberFromString.js +0 -6
- package/min/exports/parsePhoneNumberFromString.js +0 -6
- package/mobile/exports/parsePhoneNumberFromString.js +0 -6
- package/source/findNumbers.js +0 -7
- package/source/findNumbers_.js +0 -10
- package/source/formatNumberForMobileDialing.test.js +0 -16
- package/source/format_.js +0 -184
- package/source/isValidNumberForRegion.js +0 -24
- package/source/parsePhoneNumberFromString.js +0 -7
- package/source/parsePhoneNumberFromString.test.js +0 -80
- package/source/parsePhoneNumberFromString_.js +0 -24
- package/source/parse_.js +0 -344
package/README.md
CHANGED
|
@@ -152,6 +152,7 @@ const phoneNumber = parsePhoneNumber(' 8 (800) 555-35-35 ', 'RU')
|
|
|
152
152
|
if (phoneNumber) {
|
|
153
153
|
phoneNumber.country === 'RU'
|
|
154
154
|
phoneNumber.number === '+78005553535'
|
|
155
|
+
phoneNumber.isPossible() === true
|
|
155
156
|
phoneNumber.isValid() === true
|
|
156
157
|
// Note: `.getType()` requires `/max` metadata: see below for an explanation.
|
|
157
158
|
phoneNumber.getType() === 'TOLL_FREE'
|
|
@@ -184,7 +185,7 @@ isPossiblePhoneNumber('8 (800) 555-35-35', 'RU') === true
|
|
|
184
185
|
isValidPhoneNumber('8 (800) 555-35-35', 'RU') === true
|
|
185
186
|
|
|
186
187
|
validatePhoneNumberLength('8 (800) 555', 'RU') === 'TOO_SHORT'
|
|
187
|
-
validatePhoneNumberLength('8 (800) 555-35-35', 'RU') === undefined
|
|
188
|
+
validatePhoneNumberLength('8 (800) 555-35-35', 'RU') === undefined // Length is valid.
|
|
188
189
|
```
|
|
189
190
|
|
|
190
191
|
`isPossiblePhoneNumber()` only validates phone number length, while `isValidPhoneNumber()` validates both phone number length and the actual phone number digits.
|
|
@@ -342,7 +343,7 @@ Such phone numbering plans are called "non-geographic", and their phone numbers
|
|
|
342
343
|
|
|
343
344
|
## API
|
|
344
345
|
|
|
345
|
-
### parsePhoneNumber(string,
|
|
346
|
+
### parsePhoneNumber(string, defaultCountry?: string | options?: object): PhoneNumber
|
|
346
347
|
|
|
347
348
|
Parses a phone number from `string`.
|
|
348
349
|
|
|
@@ -362,11 +363,11 @@ Returns an instance of [`PhoneNumber`](#phonenumber) class, or `undefined` if no
|
|
|
362
363
|
|
|
363
364
|
Available `options`:
|
|
364
365
|
|
|
365
|
-
* `defaultCountry: string` — Default [country](#country-code) for parsing
|
|
366
|
+
* `defaultCountry: string` — Default [country](#country-code) for parsing numbers written in non-international form (without a `+` sign). Will be ignored when parsing numbers written in international form (with a `+` sign). Instead of passing it as `options.defaultCountry`, one could also pass it as a standalone `defaultCountry` argument (for convenience).
|
|
366
367
|
|
|
367
|
-
* `defaultCallingCode: string` — Default
|
|
368
|
+
* `defaultCallingCode: string` — Default calling code for parsing numbers written in non-international form (without a `+` sign). Will be ignored when parsing numbers written in international form (with a `+` sign). It could be specified when parsing phone numbers belonging to ["non-geographic numbering plans"](#non-geographic) which by nature don't have a country code, making the `defaultCountry` option unusable.
|
|
368
369
|
|
|
369
|
-
* `extract: boolean` — Defines the ["strictness"](#strictness) of parsing a phone number.
|
|
370
|
+
* `extract: boolean` — Defines the ["strictness"](#strictness) of parsing a phone number. By default, the `extract` flag is `true` meaning that it will attempt to extract the phone number from an input string like `"My phone number is (213) 373-4253 and my hair is blue"`. This could be thought of as "less strict" parsing. To make it "more strict", one could pass `extract: false` flag, in which case the function will attempt to parse the input string as if the whole string was a phone number. Applied to the example above, it would return `undefined` because the entire string is not a phone number, but for input string `"(213) 373-4253"` it would return a parsed `PhoneNumber`.
|
|
370
371
|
|
|
371
372
|
If a developer wants to know the exact reason why the phone number couldn't be parsed then they can use `parsePhoneNumberWithError()` function which throws the exact error:
|
|
372
373
|
|
|
@@ -374,7 +375,9 @@ If a developer wants to know the exact reason why the phone number couldn't be p
|
|
|
374
375
|
import { parsePhoneNumberWithError, ParseError } from 'libphonenumber-js'
|
|
375
376
|
|
|
376
377
|
try {
|
|
377
|
-
const phoneNumber = parsePhoneNumberWithError('(213) 373-42-53 ext. 1234',
|
|
378
|
+
const phoneNumber = parsePhoneNumberWithError('(213) 373-42-53 ext. 1234', {
|
|
379
|
+
defaultCountry: 'US'
|
|
380
|
+
})
|
|
378
381
|
} catch (error) {
|
|
379
382
|
if (error instanceof ParseError) {
|
|
380
383
|
// Not a phone number, non-existent country, etc.
|
|
@@ -415,6 +418,11 @@ parsePhoneNumber('Call: (213) 373-4253', {
|
|
|
415
418
|
defaultCountry: 'US',
|
|
416
419
|
extract: false
|
|
417
420
|
}) === undefined
|
|
421
|
+
|
|
422
|
+
parsePhoneNumber('(213) 373-4253', {
|
|
423
|
+
defaultCountry: 'US',
|
|
424
|
+
extract: false
|
|
425
|
+
}) === PhoneNumber
|
|
418
426
|
```
|
|
419
427
|
|
|
420
428
|
### `PhoneNumber`
|
|
@@ -539,6 +547,45 @@ Is just an alias for `this.isValid() && this.country === country`.
|
|
|
539
547
|
https://github.com/googlei18n/libphonenumber/blob/master/FAQ.md#when-should-i-use-isvalidnumberforregion
|
|
540
548
|
-->
|
|
541
549
|
|
|
550
|
+
<!--
|
|
551
|
+
See the comments for `validateLength()` method in `PhoneNumber.js` class for the rationale on why is this method not part of the public API.
|
|
552
|
+
|
|
553
|
+
#### `validateLength(): string?`
|
|
554
|
+
|
|
555
|
+
Checks if the phone number length is valid. If it is, then nothing is returned. Otherwise, a rejection reason is returned.
|
|
556
|
+
|
|
557
|
+
```js
|
|
558
|
+
parsePhoneNumber('444 1 44', 'TR').validateLength() === 'TOO_SHORT'
|
|
559
|
+
parsePhoneNumber('444 1 444', 'TR').validateLength() === undefined // Length is valid.
|
|
560
|
+
parsePhoneNumber('444 1 4444', 'TR').validateLength() === 'INVALID_LENGTH'
|
|
561
|
+
parsePhoneNumber('444 1 44444', 'TR').validateLength() === 'INVALID_LENGTH'
|
|
562
|
+
parsePhoneNumber('444 1 444444', 'TR').validateLength() === undefined // Length is valid.
|
|
563
|
+
parsePhoneNumber('444 1 4444444444', 'TR').validateLength() === 'TOO_LONG'
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
<details>
|
|
567
|
+
<summary>Possible rejection reasons</summary>
|
|
568
|
+
|
|
569
|
+
* `NOT_A_NUMBER` — When the supplied string is not a phone number. For example, when there are no digits: `"abcde"`, `"+"`.
|
|
570
|
+
|
|
571
|
+
* `INVALID_COUNTRY`
|
|
572
|
+
|
|
573
|
+
* When `defaultCountry` doesn't exist (or isn't supported by this library yet): `parsePhoneNumber('(111) 222-3333', 'XX')`.
|
|
574
|
+
* When parsing a non-international number without a `defaultCountry`: `parsePhoneNumber('(111) 222-3333')`.
|
|
575
|
+
* When an international number's country calling code doesn't exist: `parsePhoneNumber('+9991112223333')`.
|
|
576
|
+
|
|
577
|
+
* `TOO_SHORT` — When the number is too short. For example, just 1 or 2 digits: `"1"`, `"+12"`.
|
|
578
|
+
|
|
579
|
+
* `TOO_LONG` — When the national (significant) number is too long (17 digits max) or when the string being parsed is too long (250 characters max).
|
|
580
|
+
|
|
581
|
+
* `INVALID_LENGTH` — When the national (significant) number is neither too short, nor too long, but somewhere in between and its length is still invalid.
|
|
582
|
+
</details>
|
|
583
|
+
|
|
584
|
+
######
|
|
585
|
+
|
|
586
|
+
`validateLength()` is just a more detailed version of `isPossible()` — if the phone number length is invalid, it returns the actual reason: `TOO_SHORT`, `TOO_LONG`, etc.
|
|
587
|
+
-->
|
|
588
|
+
|
|
542
589
|
#### `getPossibleCountries(): string[]`
|
|
543
590
|
|
|
544
591
|
Returns a list of countries this phone number could possibly belong to.
|
|
@@ -606,7 +653,7 @@ Returns `true` if the number belongs to a ["non-geographic numbering plan"](#non
|
|
|
606
653
|
|
|
607
654
|
Compares two `PhoneNumber`s: returns `true` if they're equal, `false` otherwise.
|
|
608
655
|
|
|
609
|
-
### `isPossiblePhoneNumber(input: string): boolean`
|
|
656
|
+
### `isPossiblePhoneNumber(input: string, defaultCountry?: string | options?: object): boolean`
|
|
610
657
|
|
|
611
658
|
Checks if `input` can be parsed as a "possible" phone number. A phone number is "possible" when it has valid length. The actual phone number digits aren't validated.
|
|
612
659
|
|
|
@@ -615,11 +662,13 @@ isPossiblePhoneNumber('8 (888) 888-88-88', 'RU') === true
|
|
|
615
662
|
isPossiblePhoneNumber('+12223333333') === true
|
|
616
663
|
```
|
|
617
664
|
|
|
665
|
+
For the description of the `defaultCountry?: string | options?: object` argument, see [`parsePhoneNumber()`](#parsephonenumberstring-defaultcountry-string-options-object-phonenumber) function description.
|
|
666
|
+
|
|
618
667
|
This function is just a shortcut for a two-step process of ["strictly"](#strictness) parsing a phone number and then calling `.isPossible()`.
|
|
619
668
|
|
|
620
|
-
### `isValidPhoneNumber(input: string): boolean`
|
|
669
|
+
### `isValidPhoneNumber(input: string, defaultCountry?: string | options?: object): boolean`
|
|
621
670
|
|
|
622
|
-
Checks if `input` can be parsed as a "valid" phone number. A phone number is "valid" when it has valid length, and the actual phone number digits match the regular expressions for
|
|
671
|
+
Checks if `input` can be parsed as a "valid" phone number. A phone number is "valid" when it has valid length, and the actual phone number digits match the regular expressions for its country.
|
|
623
672
|
|
|
624
673
|
```js
|
|
625
674
|
isValidPhoneNumber('8 (888) 888-88-88', 'RU') === false
|
|
@@ -628,11 +677,47 @@ isValidPhoneNumber('+12223333333') === false
|
|
|
628
677
|
isValidPhoneNumber('+12133734253') === true
|
|
629
678
|
```
|
|
630
679
|
|
|
680
|
+
For the description of the `defaultCountry?: string | options?: object` argument, see [`parsePhoneNumber()`](#parsephonenumberstring-defaultcountry-string-options-object-phonenumber) function description.
|
|
681
|
+
|
|
631
682
|
This function is just a shortcut for a two-step process of ["strictly"](#strictness) parsing a phone number and then calling `.isValid()`.
|
|
632
683
|
|
|
633
684
|
See ["Using phone number validation feature"](#using-phone-number-validation-feature) for choosing between `isPossible()` and `isValid()`.
|
|
634
685
|
|
|
635
|
-
### `
|
|
686
|
+
### `isValidPhoneNumberForCountry(input: string, country: string): boolean`
|
|
687
|
+
|
|
688
|
+
Same as `isValidPhoneNumber()` but with the "default country" argument being an "exact country" instead.
|
|
689
|
+
|
|
690
|
+
This function is not currently exported from this library. The reason is that its result would be too vague when `false` is returned — it could mean any of:
|
|
691
|
+
|
|
692
|
+
* The input is not a valid phone number.
|
|
693
|
+
* The input is a valid phone number but it belongs to another country.
|
|
694
|
+
* The input is a phone number that belongs to the correct country but is not valid.
|
|
695
|
+
|
|
696
|
+
At least the second case should be handled separately from a "User Experience" point of view: if the user has input a valid phone number but for another country, they should be notified that "the country is incorrect" rather than that "the phone number is incorrect", otherwise it would be bad UX design.
|
|
697
|
+
|
|
698
|
+
But for those who'd still like to have such function, here's a possible implementation for it:
|
|
699
|
+
|
|
700
|
+
```js
|
|
701
|
+
export default function isValidPhoneNumberForCountry(phoneNumberString, country) {
|
|
702
|
+
const phoneNumber = parsePhoneNumber(phoneNumberString, {
|
|
703
|
+
defaultCountry: country,
|
|
704
|
+
// Demand that the entire input string must be a phone number.
|
|
705
|
+
// Otherwise, it would "extract" a phone number from an input string.
|
|
706
|
+
extract: false
|
|
707
|
+
})
|
|
708
|
+
if (!phoneNumber) {
|
|
709
|
+
return false
|
|
710
|
+
}
|
|
711
|
+
if (phoneNumber.country !== country) {
|
|
712
|
+
return false
|
|
713
|
+
}
|
|
714
|
+
return phoneNumber.isValid()
|
|
715
|
+
}
|
|
716
|
+
```
|
|
717
|
+
|
|
718
|
+
The same approach could be used to implement an `isPossiblePhoneNumberForCountry()` function.
|
|
719
|
+
|
|
720
|
+
### `validatePhoneNumberLength(input: string, defaultCountry?: string | options?: object): string?`
|
|
636
721
|
|
|
637
722
|
Checks if `input` phone number length is valid. If it is, then nothing is returned. Otherwise, a rejection reason is returned.
|
|
638
723
|
|
|
@@ -660,24 +745,26 @@ Checks if `input` phone number length is valid. If it is, then nothing is return
|
|
|
660
745
|
validatePhoneNumberLength('abcde') === 'NOT_A_NUMBER'
|
|
661
746
|
validatePhoneNumberLength('444 1 44') === 'INVALID_COUNTRY'
|
|
662
747
|
validatePhoneNumberLength('444 1 44', 'TR') === 'TOO_SHORT'
|
|
663
|
-
validatePhoneNumberLength('444 1 444', 'TR') === undefined
|
|
748
|
+
validatePhoneNumberLength('444 1 444', 'TR') === undefined // Length is valid.
|
|
664
749
|
validatePhoneNumberLength('444 1 4444', 'TR') === 'INVALID_LENGTH'
|
|
665
750
|
validatePhoneNumberLength('444 1 44444', 'TR') === 'INVALID_LENGTH'
|
|
666
|
-
validatePhoneNumberLength('444 1 444444', 'TR') === undefined
|
|
751
|
+
validatePhoneNumberLength('444 1 444444', 'TR') === undefined // Length is valid.
|
|
667
752
|
validatePhoneNumberLength('444 1 4444444444', 'TR') === 'TOO_LONG'
|
|
668
753
|
```
|
|
669
754
|
|
|
755
|
+
For the description of the `defaultCountry?: string | options?: object` argument, see [`parsePhoneNumber()`](#parsephonenumberstring-defaultcountry-string-options-object-phonenumber) function description.
|
|
756
|
+
|
|
670
757
|
This function is just a more detailed version of `isPossiblePhoneNumber()` for those who've [asked](https://github.com/catamphetamine/libphonenumber-js/issues/406) for a more specific rejection reason.
|
|
671
758
|
|
|
672
|
-
|
|
759
|
+
<!-- This function is just a shortcut for a two-step process of ["strictly"](#strictness) parsing a phone number and then calling `.validateLength()`. -->
|
|
673
760
|
|
|
674
|
-
|
|
761
|
+
The phone number is parsed ["strictly"](#strictness) from the input string.
|
|
675
762
|
|
|
676
|
-
|
|
763
|
+
### `class` AsYouType(defaultCountry?: string | options?: object)
|
|
677
764
|
|
|
678
|
-
|
|
765
|
+
Creates a formatter for a partially entered phone number.
|
|
679
766
|
|
|
680
|
-
|
|
767
|
+
For the description of the `defaultCountry?: string | options?: object` argument, see [`parsePhoneNumber()`](#parsephonenumberstring-defaultcountry-string-options-object-phonenumber) function description.
|
|
681
768
|
|
|
682
769
|
The formatter instance has the following methods:
|
|
683
770
|
|
|
@@ -790,15 +877,11 @@ asYouType.getNationalNumber() === '2133734253'
|
|
|
790
877
|
|
|
791
878
|
Google's "As You Type" formatter does not support entering phone number extensions. If your project requires phone number extensions input then use a separate input field for that.
|
|
792
879
|
|
|
793
|
-
### findPhoneNumbersInText(text: string,
|
|
880
|
+
### findPhoneNumbersInText(text: string, defaultCountry?: string | options?: object): object[]
|
|
794
881
|
|
|
795
882
|
Searches for phone numbers in `text`.
|
|
796
883
|
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
* `defaultCountry` — Default [country](#country-code) for parsing national numbers. Instead of passing `options.defaultCountry` one could pass `defaultCountry` argument directly.
|
|
800
|
-
|
|
801
|
-
* `defaultCallingCode` — Default calling code for parsing national numbers. Some numbering plans are for ["non-geographic numbering plans"](#non-geographic) and they don't have a country code, so `defaultCountry` can't be specified for them.
|
|
884
|
+
For the description of the `defaultCountry?: string | options?: object` argument, see [`parsePhoneNumber()`](#parsephonenumberstring-defaultcountry-string-options-object-phonenumber) function description.
|
|
802
885
|
|
|
803
886
|
```js
|
|
804
887
|
import { findPhoneNumbersInText } from 'libphonenumber-js'
|
|
@@ -1301,7 +1384,7 @@ The precise regular expressions aren't included in the default metadata because
|
|
|
1301
1384
|
<details>
|
|
1302
1385
|
<summary><code>isValidNumberForRegion()</code></summary>
|
|
1303
1386
|
|
|
1304
|
-
The optional `defaultCountry` argument is the _default_ country, i.e. it does not restrict to just that country, e.g. in those cases where several countries share the same phone numbering rules (NANPA, Britain, etc). For example, even though the number `07624 369230` belongs to the Isle of Man ("IM" country code) calling `isValidNumber('07624369230', 'GB')` still returns `true` because the country is not restricted to `GB`, it's just that `GB` is the default one for the phone numbering rules. For restricting the country see `isValidNumberForRegion()
|
|
1387
|
+
The optional `defaultCountry` argument is the _default_ country, i.e. it does not restrict to just that country, e.g. in those cases where several countries share the same phone numbering rules (NANPA, Britain, etc). For example, even though the number `07624 369230` belongs to the Isle of Man ("IM" country code) calling `isValidNumber('07624369230', 'GB')` still returns `true` because the country is not restricted to `GB`, it's just that `GB` is the default one for the phone numbering rules. For restricting the country, see `isValidNumberForRegion()`, though restricting a country [might not be a good idea](https://github.com/googlei18n/libphonenumber/blob/master/FAQ.md#when-should-i-use-isvalidnumberforregion).
|
|
1305
1388
|
|
|
1306
1389
|
```js
|
|
1307
1390
|
// Even though '07624 369230' number belongs to the Isle of Man ("IM")
|
package/build/PhoneNumber.js
CHANGED
|
@@ -5,19 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _metadata = _interopRequireDefault(require("./metadata.js"));
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _isPossible = _interopRequireDefault(require("./isPossible.js"));
|
|
11
11
|
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
var _isValidNumberForRegion_ = _interopRequireDefault(require("./isValidNumberForRegion_.js"));
|
|
12
|
+
var _isValid = _interopRequireDefault(require("./isValid.js"));
|
|
15
13
|
|
|
16
14
|
var _getNumberType = _interopRequireDefault(require("./helpers/getNumberType.js"));
|
|
17
15
|
|
|
18
16
|
var _getPossibleCountriesForNumber = _interopRequireDefault(require("./helpers/getPossibleCountriesForNumber.js"));
|
|
19
17
|
|
|
20
|
-
var
|
|
18
|
+
var _format2 = _interopRequireDefault(require("./format.js"));
|
|
21
19
|
|
|
22
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
21
|
|
|
@@ -36,10 +34,10 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
36
34
|
var USE_NON_GEOGRAPHIC_COUNTRY_CODE = false;
|
|
37
35
|
|
|
38
36
|
var PhoneNumber = /*#__PURE__*/function () {
|
|
39
|
-
function PhoneNumber(
|
|
37
|
+
function PhoneNumber(countryOrCountryCallingCode, nationalNumber, metadata) {
|
|
40
38
|
_classCallCheck(this, PhoneNumber);
|
|
41
39
|
|
|
42
|
-
if (!
|
|
40
|
+
if (!countryOrCountryCallingCode) {
|
|
43
41
|
throw new TypeError('`country` or `countryCallingCode` not passed');
|
|
44
42
|
}
|
|
45
43
|
|
|
@@ -51,25 +49,11 @@ var PhoneNumber = /*#__PURE__*/function () {
|
|
|
51
49
|
throw new TypeError('`metadata` not passed');
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (isCountryCode(countryCallingCode)) {
|
|
59
|
-
this.country = countryCallingCode;
|
|
60
|
-
|
|
61
|
-
_metadata.country(countryCallingCode);
|
|
62
|
-
|
|
63
|
-
countryCallingCode = _metadata.countryCallingCode();
|
|
64
|
-
} else {
|
|
65
|
-
/* istanbul ignore if */
|
|
66
|
-
if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {
|
|
67
|
-
if (_metadata.isNonGeographicCallingCode(countryCallingCode)) {
|
|
68
|
-
this.country = '001';
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
52
|
+
var _getCountryAndCountry = getCountryAndCountryCallingCode(countryOrCountryCallingCode, metadata),
|
|
53
|
+
country = _getCountryAndCountry.country,
|
|
54
|
+
countryCallingCode = _getCountryAndCountry.countryCallingCode;
|
|
72
55
|
|
|
56
|
+
this.country = country;
|
|
73
57
|
this.countryCallingCode = countryCallingCode;
|
|
74
58
|
this.nationalNumber = nationalNumber;
|
|
75
59
|
this.number = '+' + this.countryCallingCode + this.nationalNumber;
|
|
@@ -93,31 +77,40 @@ var PhoneNumber = /*#__PURE__*/function () {
|
|
|
93
77
|
}, {
|
|
94
78
|
key: "isPossible",
|
|
95
79
|
value: function isPossible() {
|
|
96
|
-
return (0,
|
|
80
|
+
return (0, _isPossible["default"])(this, {
|
|
97
81
|
v2: true
|
|
98
82
|
}, this.metadata);
|
|
99
83
|
}
|
|
100
84
|
}, {
|
|
101
85
|
key: "isValid",
|
|
102
86
|
value: function isValid() {
|
|
103
|
-
return (0,
|
|
87
|
+
return (0, _isValid["default"])(this, {
|
|
104
88
|
v2: true
|
|
105
89
|
}, this.metadata);
|
|
106
90
|
}
|
|
107
91
|
}, {
|
|
108
92
|
key: "isNonGeographic",
|
|
109
93
|
value: function isNonGeographic() {
|
|
110
|
-
var metadata = new
|
|
94
|
+
var metadata = new _metadata["default"](this.metadata);
|
|
111
95
|
return metadata.isNonGeographicCallingCode(this.countryCallingCode);
|
|
112
96
|
}
|
|
113
97
|
}, {
|
|
114
98
|
key: "isEqual",
|
|
115
99
|
value: function isEqual(phoneNumber) {
|
|
116
100
|
return this.number === phoneNumber.number && this.ext === phoneNumber.ext;
|
|
117
|
-
} //
|
|
118
|
-
//
|
|
119
|
-
//
|
|
120
|
-
//
|
|
101
|
+
} // This function was originally meant to be an equivalent for `validatePhoneNumberLength()`,
|
|
102
|
+
// but later it was found out that it doesn't include the possible `TOO_SHORT` result
|
|
103
|
+
// returned from `parsePhoneNumberWithError()` in the original `validatePhoneNumberLength()`,
|
|
104
|
+
// so eventually I simply commented out this method from the `PhoneNumber` class
|
|
105
|
+
// and just left the `validatePhoneNumberLength()` function, even though that one would require
|
|
106
|
+
// and additional step to also validate the actual country / calling code of the phone number.
|
|
107
|
+
// validateLength() {
|
|
108
|
+
// const metadata = new Metadata(this.metadata)
|
|
109
|
+
// metadata.selectNumberingPlan(this.countryCallingCode)
|
|
110
|
+
// const result = checkNumberLength(this.nationalNumber, metadata)
|
|
111
|
+
// if (result !== 'IS_POSSIBLE') {
|
|
112
|
+
// return result
|
|
113
|
+
// }
|
|
121
114
|
// }
|
|
122
115
|
|
|
123
116
|
}, {
|
|
@@ -130,7 +123,7 @@ var PhoneNumber = /*#__PURE__*/function () {
|
|
|
130
123
|
}, {
|
|
131
124
|
key: "format",
|
|
132
125
|
value: function format(_format, options) {
|
|
133
|
-
return (0,
|
|
126
|
+
return (0, _format2["default"])(this, _format, options ? _objectSpread(_objectSpread({}, options), {}, {
|
|
134
127
|
v2: true
|
|
135
128
|
}) : {
|
|
136
129
|
v2: true
|
|
@@ -161,4 +154,31 @@ exports["default"] = PhoneNumber;
|
|
|
161
154
|
var isCountryCode = function isCountryCode(value) {
|
|
162
155
|
return /^[A-Z]{2}$/.test(value);
|
|
163
156
|
};
|
|
157
|
+
|
|
158
|
+
function getCountryAndCountryCallingCode(countryOrCountryCallingCode, metadataJson) {
|
|
159
|
+
var country;
|
|
160
|
+
var countryCallingCode;
|
|
161
|
+
var metadata = new _metadata["default"](metadataJson); // If country code is passed then derive `countryCallingCode` from it.
|
|
162
|
+
// Also store the country code as `.country`.
|
|
163
|
+
|
|
164
|
+
if (isCountryCode(countryOrCountryCallingCode)) {
|
|
165
|
+
country = countryOrCountryCallingCode;
|
|
166
|
+
metadata.selectNumberingPlan(country);
|
|
167
|
+
countryCallingCode = metadata.countryCallingCode();
|
|
168
|
+
} else {
|
|
169
|
+
countryCallingCode = countryOrCountryCallingCode;
|
|
170
|
+
/* istanbul ignore if */
|
|
171
|
+
|
|
172
|
+
if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {
|
|
173
|
+
if (metadata.isNonGeographicCallingCode(countryCallingCode)) {
|
|
174
|
+
country = '001';
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
country: country,
|
|
181
|
+
countryCallingCode: countryCallingCode
|
|
182
|
+
};
|
|
183
|
+
}
|
|
164
184
|
//# sourceMappingURL=PhoneNumber.js.map
|
package/build/PhoneNumber.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhoneNumber.js","names":["USE_NON_GEOGRAPHIC_COUNTRY_CODE","PhoneNumber","
|
|
1
|
+
{"version":3,"file":"PhoneNumber.js","names":["USE_NON_GEOGRAPHIC_COUNTRY_CODE","PhoneNumber","countryOrCountryCallingCode","nationalNumber","metadata","TypeError","getCountryAndCountryCallingCode","country","countryCallingCode","number","ext","getPossibleCountriesForNumber","isPossibleNumber","v2","isValidNumber","Metadata","isNonGeographicCallingCode","phoneNumber","getNumberType","format","options","formatNumber","isCountryCode","value","test","metadataJson","selectNumberingPlan"],"sources":["../source/PhoneNumber.js"],"sourcesContent":["import Metadata from './metadata.js'\r\nimport isPossibleNumber from './isPossible.js'\r\nimport isValidNumber from './isValid.js'\r\n// import checkNumberLength from './helpers/checkNumberLength.js'\r\nimport getNumberType from './helpers/getNumberType.js'\r\nimport getPossibleCountriesForNumber from './helpers/getPossibleCountriesForNumber.js'\r\nimport formatNumber from './format.js'\r\n\r\nconst USE_NON_GEOGRAPHIC_COUNTRY_CODE = false\r\n\r\nexport default class PhoneNumber {\r\n\tconstructor(countryOrCountryCallingCode, nationalNumber, metadata) {\r\n\t\tif (!countryOrCountryCallingCode) {\r\n\t\t\tthrow new TypeError('`country` or `countryCallingCode` not passed')\r\n\t\t}\r\n\t\tif (!nationalNumber) {\r\n\t\t\tthrow new TypeError('`nationalNumber` not passed')\r\n\t\t}\r\n\t\tif (!metadata) {\r\n\t\t\tthrow new TypeError('`metadata` not passed')\r\n\t\t}\r\n\t\tconst { country, countryCallingCode } = getCountryAndCountryCallingCode(\r\n\t\t\tcountryOrCountryCallingCode,\r\n\t\t\tmetadata\r\n\t\t)\r\n\t\tthis.country = country\r\n\t\tthis.countryCallingCode = countryCallingCode\r\n\t\tthis.nationalNumber = nationalNumber\r\n\t\tthis.number = '+' + this.countryCallingCode + this.nationalNumber\r\n\t\tthis.metadata = metadata\r\n\t}\r\n\r\n\tsetExt(ext) {\r\n\t\tthis.ext = ext\r\n\t}\r\n\r\n\tgetPossibleCountries() {\r\n\t\tif (this.country) {\r\n\t\t\treturn [this.country]\r\n\t\t}\r\n\t\treturn getPossibleCountriesForNumber(\r\n\t\t\tthis.countryCallingCode,\r\n\t\t\tthis.nationalNumber,\r\n\t\t\tthis.metadata\r\n\t\t)\r\n\t}\r\n\r\n\tisPossible() {\r\n\t\treturn isPossibleNumber(this, { v2: true }, this.metadata)\r\n\t}\r\n\r\n\tisValid() {\r\n\t\treturn isValidNumber(this, { v2: true }, this.metadata)\r\n\t}\r\n\r\n\tisNonGeographic() {\r\n\t\tconst metadata = new Metadata(this.metadata)\r\n\t\treturn metadata.isNonGeographicCallingCode(this.countryCallingCode)\r\n\t}\r\n\r\n\tisEqual(phoneNumber) {\r\n\t\treturn this.number === phoneNumber.number && this.ext === phoneNumber.ext\r\n\t}\r\n\r\n\t// This function was originally meant to be an equivalent for `validatePhoneNumberLength()`,\r\n\t// but later it was found out that it doesn't include the possible `TOO_SHORT` result\r\n\t// returned from `parsePhoneNumberWithError()` in the original `validatePhoneNumberLength()`,\r\n\t// so eventually I simply commented out this method from the `PhoneNumber` class\r\n\t// and just left the `validatePhoneNumberLength()` function, even though that one would require\r\n\t// and additional step to also validate the actual country / calling code of the phone number.\r\n\t// validateLength() {\r\n\t// \tconst metadata = new Metadata(this.metadata)\r\n\t// \tmetadata.selectNumberingPlan(this.countryCallingCode)\r\n\t// \tconst result = checkNumberLength(this.nationalNumber, metadata)\r\n\t// \tif (result !== 'IS_POSSIBLE') {\r\n\t// \t\treturn result\r\n\t// \t}\r\n\t// }\r\n\r\n\tgetType() {\r\n\t\treturn getNumberType(this, { v2: true }, this.metadata)\r\n\t}\r\n\r\n\tformat(format, options) {\r\n\t\treturn formatNumber(\r\n\t\t\tthis,\r\n\t\t\tformat,\r\n\t\t\toptions ? { ...options, v2: true } : { v2: true },\r\n\t\t\tthis.metadata\r\n\t\t)\r\n\t}\r\n\r\n\tformatNational(options) {\r\n\t\treturn this.format('NATIONAL', options)\r\n\t}\r\n\r\n\tformatInternational(options) {\r\n\t\treturn this.format('INTERNATIONAL', options)\r\n\t}\r\n\r\n\tgetURI(options) {\r\n\t\treturn this.format('RFC3966', options)\r\n\t}\r\n}\r\n\r\nconst isCountryCode = (value) => /^[A-Z]{2}$/.test(value)\r\n\r\nfunction getCountryAndCountryCallingCode(countryOrCountryCallingCode, metadataJson) {\r\n\tlet country\r\n\tlet countryCallingCode\r\n\r\n\tconst metadata = new Metadata(metadataJson)\r\n\t// If country code is passed then derive `countryCallingCode` from it.\r\n\t// Also store the country code as `.country`.\r\n\tif (isCountryCode(countryOrCountryCallingCode)) {\r\n\t\tcountry = countryOrCountryCallingCode\r\n\t\tmetadata.selectNumberingPlan(country)\r\n\t\tcountryCallingCode = metadata.countryCallingCode()\r\n\t} else {\r\n\t\tcountryCallingCode = countryOrCountryCallingCode\r\n\t\t/* istanbul ignore if */\r\n\t\tif (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {\r\n\t\t\tif (metadata.isNonGeographicCallingCode(countryCallingCode)) {\r\n\t\t\t\tcountry = '001'\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn {\r\n\t\tcountry,\r\n\t\tcountryCallingCode\r\n\t}\r\n}"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;;;;;;;AAEA,IAAMA,+BAA+B,GAAG,KAAxC;;IAEqBC,W;EACpB,qBAAYC,2BAAZ,EAAyCC,cAAzC,EAAyDC,QAAzD,EAAmE;IAAA;;IAClE,IAAI,CAACF,2BAAL,EAAkC;MACjC,MAAM,IAAIG,SAAJ,CAAc,8CAAd,CAAN;IACA;;IACD,IAAI,CAACF,cAAL,EAAqB;MACpB,MAAM,IAAIE,SAAJ,CAAc,6BAAd,CAAN;IACA;;IACD,IAAI,CAACD,QAAL,EAAe;MACd,MAAM,IAAIC,SAAJ,CAAc,uBAAd,CAAN;IACA;;IACD,4BAAwCC,+BAA+B,CACtEJ,2BADsE,EAEtEE,QAFsE,CAAvE;IAAA,IAAQG,OAAR,yBAAQA,OAAR;IAAA,IAAiBC,kBAAjB,yBAAiBA,kBAAjB;;IAIA,KAAKD,OAAL,GAAeA,OAAf;IACA,KAAKC,kBAAL,GAA0BA,kBAA1B;IACA,KAAKL,cAAL,GAAsBA,cAAtB;IACA,KAAKM,MAAL,GAAc,MAAM,KAAKD,kBAAX,GAAgC,KAAKL,cAAnD;IACA,KAAKC,QAAL,GAAgBA,QAAhB;EACA;;;;WAED,gBAAOM,GAAP,EAAY;MACX,KAAKA,GAAL,GAAWA,GAAX;IACA;;;WAED,gCAAuB;MACtB,IAAI,KAAKH,OAAT,EAAkB;QACjB,OAAO,CAAC,KAAKA,OAAN,CAAP;MACA;;MACD,OAAO,IAAAI,yCAAA,EACN,KAAKH,kBADC,EAEN,KAAK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AAY,SAAZ,EAAuBC,OAAvB,CAAP;IACA;;;;;;;;AAGF,IAAME,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD;EAAA,OAAW,aAAaC,IAAb,CAAkBD,KAAlB,CAAX;AAAA,CAAtB;;AAEA,SAASjB,+BAAT,CAAyCJ,2BAAzC,EAAsEuB,YAAtE,EAAoF;EACnF,IAAIlB,OAAJ;EACA,IAAIC,kBAAJ;EAEA,IAAMJ,QAAQ,GAAG,IAAIW,oBAAJ,CAAaU,YAAb,CAAjB,CAJmF,CAKnF;EACA;;EACA,IAAIH,aAAa,CAACpB,2BAAD,CAAjB,EAAgD;IAC/CK,OAAO,GAAGL,2BAAV;IACAE,QAAQ,CAACsB,mBAAT,CAA6BnB,OAA7B;IACAC,kBAAkB,GAAGJ,QAAQ,CAACI,kBAAT,EAArB;EACA,CAJD,MAIO;IACNA,kBAAkB,GAAGN,2BAArB;IACA;;IACA,IAAIF,+BAAJ,EAAqC;MACpC,IAAII,QAAQ,CAACY,0BAAT,CAAoCR,kBAApC,CAAJ,EAA6D;QAC5DD,OAAO,GAAG,KAAV;MACA;IACD;EACD;;EAED,OAAO;IACNA,OAAO,EAAPA,OADM;IAENC,kBAAkB,EAAlBA;EAFM,CAAP;AAIA"}
|
|
@@ -91,6 +91,12 @@ describe('PhoneNumber', function () {
|
|
|
91
91
|
var phoneNumber = new _PhoneNumber["default"]('777', '123', _metadataMin["default"]);
|
|
92
92
|
expect(phoneNumber.country).to.be.undefined;
|
|
93
93
|
phoneNumber.getPossibleCountries().should.deep.equal([]);
|
|
94
|
-
});
|
|
94
|
+
}); // it('should validate phone number length', () => {
|
|
95
|
+
// const phoneNumber = new PhoneNumber('RU', '800', metadata)
|
|
96
|
+
// expect(phoneNumber.validateLength()).to.equal('TOO_SHORT')
|
|
97
|
+
//
|
|
98
|
+
// const phoneNumberValid = new PhoneNumber('RU', '8005553535', metadata)
|
|
99
|
+
// expect(phoneNumberValid.validateLength()).to.be.undefined
|
|
100
|
+
// })
|
|
95
101
|
});
|
|
96
102
|
//# sourceMappingURL=PhoneNumber.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhoneNumber.test.js","names":["describe","it","expect","PhoneNumber","to","phoneNumber","metadata","countryCallingCode","should","equal","country","number","ext","format","formatExtension","extension","isEqual","isNonGeographic","setExt","formatNational","be","undefined","getPossibleCountries","deep","indexOf","length"],"sources":["../source/PhoneNumber.test.js"],"sourcesContent":["import metadata from '../metadata.min.json' assert { type: 'json' }\r\nimport PhoneNumber from './PhoneNumber.js'\r\n\r\ndescribe('PhoneNumber', () => {\r\n\tit('should validate constructor arguments', () => {\r\n\t\texpect(() => new PhoneNumber()).to.throw('`countryCallingCode` not passed')\r\n\t\texpect(() => new PhoneNumber('7')).to.throw('`nationalNumber` not passed')\r\n\t\texpect(() => new PhoneNumber('7', '8005553535')).to.throw('`metadata` not passed')\r\n\t})\r\n\r\n\tit('should accept country code argument', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('RU', '8005553535', metadata)\r\n\t\tphoneNumber.countryCallingCode.should.equal('7')\r\n\t\tphoneNumber.country.should.equal('RU')\r\n\t\tphoneNumber.number.should.equal('+78005553535')\r\n\t})\r\n\r\n\tit('should format number with options', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('7', '8005553535', metadata)\r\n\t\tphoneNumber.ext = '123'\r\n\t\tphoneNumber.format('NATIONAL', {\r\n\t\t\tformatExtension: (number, extension) => `${number} доб. ${extension}`\r\n\t\t})\r\n\t\t.should.equal('8 (800) 555-35-35 доб. 123')\r\n\t})\r\n\r\n\tit('should compare phone numbers', () => {\r\n\t\tnew PhoneNumber('RU', '8005553535', metadata).isEqual(new PhoneNumber('RU', '8005553535', metadata)).should.equal(true)\r\n\t\tnew PhoneNumber('RU', '8005553535', metadata).isEqual(new PhoneNumber('7', '8005553535', metadata)).should.equal(true)\r\n\t\tnew PhoneNumber('RU', '8005553535', metadata).isEqual(new PhoneNumber('RU', '8005553536', metadata)).should.equal(false)\r\n\t})\r\n\r\n\tit('should tell if a number is non-geographic', () => {\r\n\t\tnew PhoneNumber('7', '8005553535', metadata).isNonGeographic().should.equal(false)\r\n\t\tnew PhoneNumber('870', '773111632', metadata).isNonGeographic().should.equal(true)\r\n\t})\r\n\r\n\tit('should allow setting extension', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('1', '2133734253', metadata)\r\n\t\tphoneNumber.setExt('1234')\r\n\t\tphoneNumber.ext.should.equal('1234')\r\n\t\tphoneNumber.formatNational().should.equal('(213) 373-4253 ext. 1234')\r\n\t})\r\n\r\n\tit('should return possible countries', () => {\r\n // \"599\": [\r\n // \"CW\", // \"possible_lengths\": [7, 8]\r\n // \"BQ\" // \"possible_lengths\": [7]\r\n // ]\r\n\r\n\t\tlet phoneNumber = new PhoneNumber('599', '123456', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal([])\r\n\r\n\t\tphoneNumber = new PhoneNumber('599', '1234567', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal(['CW', 'BQ'])\r\n\r\n\t\tphoneNumber = new PhoneNumber('599', '12345678', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal(['CW'])\r\n\r\n\t\tphoneNumber = new PhoneNumber('599', '123456789', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal([])\r\n\t})\r\n\r\n\tit('should return possible countries in case of ambiguity', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('1', '2223334444', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().indexOf('US').should.equal(0)\r\n\t\tphoneNumber.getPossibleCountries().length.should.equal(25)\r\n\t})\r\n\r\n\t// it('should return empty possible countries when no national number has been input', () => {\r\n\t// \tconst phoneNumber = new PhoneNumber('1', '', metadata)\r\n\t// \texpect(phoneNumber.country).to.be.undefined\r\n\t// \tphoneNumber.getPossibleCountries().should.deep.equal([])\r\n\t// })\r\n\r\n\tit('should return empty possible countries when not enough national number digits have been input', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('1', '222', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal([])\r\n\t})\r\n\r\n\tit('should return possible countries in case of no ambiguity', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('US', '2133734253', metadata)\r\n\t\tphoneNumber.country.should.equal('US')\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal(['US'])\r\n\t})\r\n\r\n\tit('should return empty possible countries in case of an unknown calling code', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('777', '123', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal([])\r\n\t})\r\n})"],"mappings":";;AAAA;;AACA;;;;AAEAA,QAAQ,CAAC,aAAD,EAAgB,YAAM;EAC7BC,EAAE,CAAC,uCAAD,EAA0C,YAAM;IACjDC,MAAM,CAAC;MAAA,OAAM,IAAIC,uBAAJ,EAAN;IAAA,CAAD,CAAN,CAAgCC,EAAhC,UAAyC,iCAAzC;IACAF,MAAM,CAAC;MAAA,OAAM,IAAIC,uBAAJ,CAAgB,GAAhB,CAAN;IAAA,CAAD,CAAN,CAAmCC,EAAnC,UAA4C,6BAA5C;IACAF,MAAM,CAAC;MAAA,OAAM,IAAIC,uBAAJ,CAAgB,GAAhB,EAAqB,YAArB,CAAN;IAAA,CAAD,CAAN,CAAiDC,EAAjD,UAA0D,uBAA1D;EACA,CAJC,CAAF;EAMAH,EAAE,CAAC,qCAAD,EAAwC,YAAM;IAC/C,IAAMI,WAAW,GAAG,IAAIF,uBAAJ,CAAgB,IAAhB,EAAsB,YAAtB,EAAoCG,uBAApC,CAApB;IACAD,WAAW,CA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CAApB;IACAJ,MAAM,CAACG,WAAW,CAACK,OAAb,CAAN,CAA4BN,EAA5B,CAA+BgB,EAA/B,CAAkCC,SAAlC;IACAhB,WAAW,CAACiB,oBAAZ,GAAmCd,MAAnC,CAA0Ce,IAA1C,CAA+Cd,KAA/C,CAAqD,EAArD;EACA,CAJC,CAAF;EAMAR,EAAE,CAAC,0DAAD,EAA6D,YAAM;IACpE,IAAMI,WAAW,GAAG,IAAIF,uBAAJ,CAAgB,IAAhB,EAAsB,YAAtB,EAAoCG,uBAApC,CAApB;IACAD,WAAW,CAACK,OAAZ,CAAoBF,MAApB,CAA2BC,KAA3B,CAAiC,IAAjC;IACAJ,WAAW,CAACiB,oBAAZ,GAAmCd,MAAnC,CAA0Ce,IAA1C,CAA+Cd,KAA/C,CAAqD,CAAC,IAAD,CAArD;EACA,CAJC,CAAF;EAMAR,EAAE,CAAC,2EAAD,EAA8E,YAAM;IACrF,IAAMI,WAAW,GAAG,IAAIF,uBAAJ,CAAgB,KAAhB,EAAuB,KAAvB,EAA8BG,uBAA9B,CAApB;IACAJ,MAAM,CAACG,WAAW,CAACK,OAAb,CAAN,CAA4BN,EAA5B,CAA+BgB,EAA/B,CAAkCC,SAAlC;IACAhB,WAAW,CAACiB,oBAAZ,GAAmCd,MAAnC,CAA0Ce,IAA1C,CAA+Cd,KAA/C,CAAqD,EAArD;EACA,CAJC,CAAF;
|
|
1
|
+
{"version":3,"file":"PhoneNumber.test.js","names":["describe","it","expect","PhoneNumber","to","phoneNumber","metadata","countryCallingCode","should","equal","country","number","ext","format","formatExtension","extension","isEqual","isNonGeographic","setExt","formatNational","be","undefined","getPossibleCountries","deep","indexOf","length"],"sources":["../source/PhoneNumber.test.js"],"sourcesContent":["import metadata from '../metadata.min.json' assert { type: 'json' }\r\nimport PhoneNumber from './PhoneNumber.js'\r\n\r\ndescribe('PhoneNumber', () => {\r\n\tit('should validate constructor arguments', () => {\r\n\t\texpect(() => new PhoneNumber()).to.throw('`countryCallingCode` not passed')\r\n\t\texpect(() => new PhoneNumber('7')).to.throw('`nationalNumber` not passed')\r\n\t\texpect(() => new PhoneNumber('7', '8005553535')).to.throw('`metadata` not passed')\r\n\t})\r\n\r\n\tit('should accept country code argument', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('RU', '8005553535', metadata)\r\n\t\tphoneNumber.countryCallingCode.should.equal('7')\r\n\t\tphoneNumber.country.should.equal('RU')\r\n\t\tphoneNumber.number.should.equal('+78005553535')\r\n\t})\r\n\r\n\tit('should format number with options', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('7', '8005553535', metadata)\r\n\t\tphoneNumber.ext = '123'\r\n\t\tphoneNumber.format('NATIONAL', {\r\n\t\t\tformatExtension: (number, extension) => `${number} доб. ${extension}`\r\n\t\t})\r\n\t\t.should.equal('8 (800) 555-35-35 доб. 123')\r\n\t})\r\n\r\n\tit('should compare phone numbers', () => {\r\n\t\tnew PhoneNumber('RU', '8005553535', metadata).isEqual(new PhoneNumber('RU', '8005553535', metadata)).should.equal(true)\r\n\t\tnew PhoneNumber('RU', '8005553535', metadata).isEqual(new PhoneNumber('7', '8005553535', metadata)).should.equal(true)\r\n\t\tnew PhoneNumber('RU', '8005553535', metadata).isEqual(new PhoneNumber('RU', '8005553536', metadata)).should.equal(false)\r\n\t})\r\n\r\n\tit('should tell if a number is non-geographic', () => {\r\n\t\tnew PhoneNumber('7', '8005553535', metadata).isNonGeographic().should.equal(false)\r\n\t\tnew PhoneNumber('870', '773111632', metadata).isNonGeographic().should.equal(true)\r\n\t})\r\n\r\n\tit('should allow setting extension', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('1', '2133734253', metadata)\r\n\t\tphoneNumber.setExt('1234')\r\n\t\tphoneNumber.ext.should.equal('1234')\r\n\t\tphoneNumber.formatNational().should.equal('(213) 373-4253 ext. 1234')\r\n\t})\r\n\r\n\tit('should return possible countries', () => {\r\n // \"599\": [\r\n // \"CW\", // \"possible_lengths\": [7, 8]\r\n // \"BQ\" // \"possible_lengths\": [7]\r\n // ]\r\n\r\n\t\tlet phoneNumber = new PhoneNumber('599', '123456', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal([])\r\n\r\n\t\tphoneNumber = new PhoneNumber('599', '1234567', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal(['CW', 'BQ'])\r\n\r\n\t\tphoneNumber = new PhoneNumber('599', '12345678', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal(['CW'])\r\n\r\n\t\tphoneNumber = new PhoneNumber('599', '123456789', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal([])\r\n\t})\r\n\r\n\tit('should return possible countries in case of ambiguity', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('1', '2223334444', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().indexOf('US').should.equal(0)\r\n\t\tphoneNumber.getPossibleCountries().length.should.equal(25)\r\n\t})\r\n\r\n\t// it('should return empty possible countries when no national number has been input', () => {\r\n\t// \tconst phoneNumber = new PhoneNumber('1', '', metadata)\r\n\t// \texpect(phoneNumber.country).to.be.undefined\r\n\t// \tphoneNumber.getPossibleCountries().should.deep.equal([])\r\n\t// })\r\n\r\n\tit('should return empty possible countries when not enough national number digits have been input', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('1', '222', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal([])\r\n\t})\r\n\r\n\tit('should return possible countries in case of no ambiguity', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('US', '2133734253', metadata)\r\n\t\tphoneNumber.country.should.equal('US')\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal(['US'])\r\n\t})\r\n\r\n\tit('should return empty possible countries in case of an unknown calling code', () => {\r\n\t\tconst phoneNumber = new PhoneNumber('777', '123', metadata)\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.getPossibleCountries().should.deep.equal([])\r\n\t})\r\n\r\n\t// it('should validate phone number length', () => {\r\n\t// \tconst phoneNumber = new PhoneNumber('RU', '800', metadata)\r\n\t// \texpect(phoneNumber.validateLength()).to.equal('TOO_SHORT')\r\n\t//\r\n\t// \tconst phoneNumberValid = new PhoneNumber('RU', '8005553535', metadata)\r\n\t// \texpect(phoneNumberValid.validateLength()).to.be.undefined\r\n\t// })\r\n})"],"mappings":";;AAAA;;AACA;;;;AAEAA,QAAQ,CAAC,aAAD,EAAgB,YAAM;EAC7BC,EAAE,CAAC,uCAAD,EAA0C,YAAM;IACjDC,MAAM,CAAC;MAAA,OAAM,IAAIC,uBAAJ,EAAN;IAAA,CAAD,CAAN,CAAgCC,EAAhC,UAAyC,iCAAzC;IACAF,MAAM,CAAC;MAAA,OAAM,IAAIC,uBAAJ,CAAgB,GAAhB,CAAN;IAAA,CAAD,CAAN,CAAmCC,EAAnC,UAA4C,6BAA5C;IACAF,MAAM,CAAC;MAAA,OAAM,IAAIC,uBAAJ,CAAgB,GAAhB,EAAqB,YAArB,CAAN;IAAA,CAAD,CAAN,CAAiDC,EAAjD,UAA0D,uBAA1D;EACA,CAJC,CAAF;EAMAH,EAAE,CAAC,qCAAD,EAAwC,YAAM;IAC/C,IAAMI,WAAW,GAAG,IAAIF,uBAAJ,CAAgB,IAAhB,EAAsB,YAAtB,EAAoCG,uBAApC,CAApB;IACAD,WAAW,CAACE,kBAAZ,CAA+BC,MAA/B,CAAsCC,KAAtC,CAA4C,GAA5C;IACAJ,WAAW,CAACK,OAAZ,CAAoBF,MAApB,CAA2BC,KAA3B,CAAiC,IAAjC;IACAJ,WAAW,CAACM,MAAZ,CAAmBH,MAAnB,CAA0BC,KAA1B,CAAgC,cAAhC;EACA,CALC,CAAF;EAOAR,EA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DAAD,EAA6D,YAAM;IACpE,IAAMI,WAAW,GAAG,IAAIF,uBAAJ,CAAgB,IAAhB,EAAsB,YAAtB,EAAoCG,uBAApC,CAApB;IACAD,WAAW,CAACK,OAAZ,CAAoBF,MAApB,CAA2BC,KAA3B,CAAiC,IAAjC;IACAJ,WAAW,CAACiB,oBAAZ,GAAmCd,MAAnC,CAA0Ce,IAA1C,CAA+Cd,KAA/C,CAAqD,CAAC,IAAD,CAArD;EACA,CAJC,CAAF;EAMAR,EAAE,CAAC,2EAAD,EAA8E,YAAM;IACrF,IAAMI,WAAW,GAAG,IAAIF,uBAAJ,CAAgB,KAAhB,EAAuB,KAAvB,EAA8BG,uBAA9B,CAApB;IACAJ,MAAM,CAACG,WAAW,CAACK,OAAb,CAAN,CAA4BN,EAA5B,CAA+BgB,EAA/B,CAAkCC,SAAlC;IACAhB,WAAW,CAACiB,oBAAZ,GAAmCd,MAAnC,CAA0Ce,IAA1C,CAA+Cd,KAA/C,CAAqD,EAArD;EACA,CAJC,CAAF,CAzF6B,CA+F7B;EACA;EACA;EACA;EACA;EACA;EACA;AACA,CAtGO,CAAR"}
|
|
@@ -29,7 +29,7 @@ var _isValidCandidate = _interopRequireWildcard(require("./findNumbers/isValidCa
|
|
|
29
29
|
|
|
30
30
|
var _metadata = require("./metadata.js");
|
|
31
31
|
|
|
32
|
-
var
|
|
32
|
+
var _parse = _interopRequireDefault(require("./parse.js"));
|
|
33
33
|
|
|
34
34
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
35
35
|
|
|
@@ -312,7 +312,7 @@ var PhoneNumberMatcher = /*#__PURE__*/function () {
|
|
|
312
312
|
return;
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
-
var number = (0,
|
|
315
|
+
var number = (0, _parse["default"])(candidate, {
|
|
316
316
|
extended: true,
|
|
317
317
|
defaultCountry: this.options.defaultCountry,
|
|
318
318
|
defaultCallingCode: this.options.defaultCallingCode
|