global-phone-validator 1.1.1 → 1.2.1
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 +73 -29
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -23
- package/dist/index.js.map +1 -1
- package/dist/mobilePrefixes.d.ts +18 -0
- package/dist/mobilePrefixes.d.ts.map +1 -0
- package/dist/mobilePrefixes.js +229 -0
- package/dist/mobilePrefixes.js.map +1 -0
- package/dist/types.d.ts +0 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# global-phone-validator
|
|
2
2
|
|
|
3
|
-
A comprehensive Node.js + TypeScript package for validating phone numbers worldwide. Supports **all countries** with **country-specific validation rules** for 50+ major countries. Handles international formats (+CC), 0-prefixed, and plain digits.
|
|
3
|
+
A comprehensive Node.js + TypeScript package for validating **mobile phone numbers** worldwide. Supports **all countries** with **country-specific validation rules** and **mobile prefix detection** for 50+ major countries. Handles international formats (+CC), 0-prefixed, and plain digits. Returns standardized E.164 format.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- ✅ **True Global Validation**: Validates phone numbers for **all countries** with country-specific rules for 50+ major countries
|
|
7
|
+
- ✅ **True Global Validation**: Validates mobile phone numbers for **all countries** with country-specific rules for 50+ major countries
|
|
8
8
|
- ✅ **Country-Specific Rules**: Accurate validation for US, UK, Germany, France, Australia, Brazil, China, Japan, India, and 40+ more countries
|
|
9
|
+
- ✅ **Mobile Prefix Detection**: Detects mobile numbers using country-specific prefix rules for 30+ countries
|
|
9
10
|
- ✅ **Multiple Formats**: Handles international format (+CC), 0-prefixed, and plain digit formats
|
|
10
|
-
- ✅ **India-Specific**: Mobile vs landline detection for Indian phone numbers
|
|
11
11
|
- ✅ **Standardized Output**: Returns E.164 format (+CCNNNNNNNNN) with country information
|
|
12
12
|
- ✅ **TypeScript**: Fully typed with TypeScript definitions
|
|
13
13
|
- ✅ **Zero Dependencies**: No external dependencies required
|
|
@@ -27,16 +27,32 @@ Test the package directly in your browser with RunKit:
|
|
|
27
27
|
|
|
28
28
|
**[▶️ Try on RunKit](https://npm.runkit.com/global-phone-validator)**
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
> **Note:** If you get a 503 error, RunKit may be temporarily unavailable or the latest version may still be indexing. Try again in a few minutes, or test locally using the code below.
|
|
31
|
+
|
|
32
|
+
### Quick Test Code
|
|
33
|
+
|
|
34
|
+
You can paste this code in RunKit or run it locally:
|
|
31
35
|
|
|
32
36
|
```javascript
|
|
33
37
|
const { validatePhoneNumber } = require("global-phone-validator");
|
|
34
38
|
|
|
35
39
|
// Test various countries
|
|
36
|
-
validatePhoneNumber("+91 98765 43210"); // India
|
|
37
|
-
validatePhoneNumber("+1 555 123 4567"); // USA
|
|
38
|
-
validatePhoneNumber("+44
|
|
39
|
-
validatePhoneNumber("+49
|
|
40
|
+
console.log(validatePhoneNumber("+91 98765 43210")); // India - Mobile
|
|
41
|
+
console.log(validatePhoneNumber("+1 555 123 4567")); // USA - Mobile
|
|
42
|
+
console.log(validatePhoneNumber("+44 7123 456789")); // UK - Mobile
|
|
43
|
+
console.log(validatePhoneNumber("+49 176 77274194")); // Germany - Mobile
|
|
44
|
+
console.log(validatePhoneNumber("+61 4 1234 5678")); // Australia - Mobile
|
|
45
|
+
console.log(validatePhoneNumber("+86 138 0013 8000")); // China - Mobile
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Test Locally
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Install the package
|
|
52
|
+
npm install global-phone-validator
|
|
53
|
+
|
|
54
|
+
# Create a test file
|
|
55
|
+
node -e "const {validatePhoneNumber} = require('global-phone-validator'); console.log(validatePhoneNumber('+91 98765 43210'));"
|
|
40
56
|
```
|
|
41
57
|
|
|
42
58
|
## Usage
|
|
@@ -55,7 +71,6 @@ console.log(result1);
|
|
|
55
71
|
// nationalNumber: '9876543210',
|
|
56
72
|
// e164: '+919876543210',
|
|
57
73
|
// isMobile: true,
|
|
58
|
-
// isFixedLine: false,
|
|
59
74
|
// country: 'IN',
|
|
60
75
|
// countryName: 'India'
|
|
61
76
|
// }
|
|
@@ -68,6 +83,18 @@ console.log(result2.isValid); // true
|
|
|
68
83
|
const result3 = validatePhoneNumber("9876543210", "IN");
|
|
69
84
|
console.log(result3.isValid); // true
|
|
70
85
|
|
|
86
|
+
// Auto-detection from country code (no defaultCountry needed)
|
|
87
|
+
const result3a = validatePhoneNumber("+4917677274194");
|
|
88
|
+
console.log(result3a.isValid); // true - Auto-detects Germany from +49
|
|
89
|
+
console.log(result3a.country); // "DE" (Germany)
|
|
90
|
+
|
|
91
|
+
// Country matching validation (strict mode with defaultCountry)
|
|
92
|
+
const result3b = validatePhoneNumber("+4917677274194", "IN");
|
|
93
|
+
console.log(result3b.isValid); // false - Germany number doesn't match IN
|
|
94
|
+
|
|
95
|
+
const result3c = validatePhoneNumber("+4917677274194", "DE");
|
|
96
|
+
console.log(result3c.isValid); // true - Germany number matches DE
|
|
97
|
+
|
|
71
98
|
// US number
|
|
72
99
|
const result4 = validatePhoneNumber("+1 555 123 4567");
|
|
73
100
|
console.log(result4);
|
|
@@ -81,15 +108,18 @@ console.log(result4);
|
|
|
81
108
|
// }
|
|
82
109
|
```
|
|
83
110
|
|
|
84
|
-
### Mobile-Only Validation
|
|
111
|
+
### Mobile-Only Validation
|
|
85
112
|
|
|
86
113
|
```typescript
|
|
87
|
-
// Only accept mobile numbers
|
|
114
|
+
// Only accept mobile numbers (works for all countries with mobile prefix rules)
|
|
88
115
|
const result = validatePhoneNumber("9876543210", "IN", true);
|
|
89
116
|
console.log(result.isValid); // true (mobile number)
|
|
90
117
|
|
|
91
|
-
const result2 = validatePhoneNumber("
|
|
92
|
-
console.log(result2.isValid); //
|
|
118
|
+
const result2 = validatePhoneNumber("17677274194", "DE", true);
|
|
119
|
+
console.log(result2.isValid); // true (German mobile number)
|
|
120
|
+
|
|
121
|
+
const result3 = validatePhoneNumber("7123456789", "GB", true);
|
|
122
|
+
console.log(result3.isValid); // true (UK mobile number)
|
|
93
123
|
```
|
|
94
124
|
|
|
95
125
|
### Get Country Codes
|
|
@@ -123,8 +153,13 @@ Validates a phone number and returns detailed information.
|
|
|
123
153
|
**Parameters:**
|
|
124
154
|
|
|
125
155
|
- `input` (string): Phone number in various formats
|
|
126
|
-
- `defaultCountry` (string, optional): ISO country code (e.g., "IN", "US")
|
|
127
|
-
-
|
|
156
|
+
- `defaultCountry` (string, optional): ISO country code (e.g., "IN", "US").
|
|
157
|
+
- **When number has `+` prefix**:
|
|
158
|
+
- Country is **auto-detected** from the dial code (e.g., `+49` → Germany, `+91` → India)
|
|
159
|
+
- If `defaultCountry` is provided: Validates that detected country **matches** `defaultCountry` (strict mode)
|
|
160
|
+
- If `defaultCountry` is **not provided**: Validates based on the **detected country** from the dial code
|
|
161
|
+
- **When number doesn't have `+` prefix**: `defaultCountry` is **REQUIRED** - no default country is assumed
|
|
162
|
+
- `mobileOnly` (boolean, optional): If true, only accepts mobile numbers (works for all countries with mobile prefix rules). Default: false
|
|
128
163
|
|
|
129
164
|
**Returns:** `PhoneValidationResult`
|
|
130
165
|
|
|
@@ -134,8 +169,7 @@ interface PhoneValidationResult {
|
|
|
134
169
|
countryCode?: string; // e.g., '91'
|
|
135
170
|
nationalNumber?: string; // e.g., '9876543210'
|
|
136
171
|
e164?: string; // e.g., '+919876543210'
|
|
137
|
-
isMobile?: boolean; // true if mobile (
|
|
138
|
-
isFixedLine?: boolean; // true if landline (India only)
|
|
172
|
+
isMobile?: boolean; // true if mobile number (based on country-specific prefix rules)
|
|
139
173
|
country?: string; // ISO country code, e.g., 'IN'
|
|
140
174
|
countryName?: string; // Full country name, e.g., 'India'
|
|
141
175
|
}
|
|
@@ -180,8 +214,12 @@ Gets country information by dial code.
|
|
|
180
214
|
The package handles phone numbers in the following formats:
|
|
181
215
|
|
|
182
216
|
1. **International format**: `+91 98765 43210` or `+919876543210`
|
|
183
|
-
|
|
184
|
-
|
|
217
|
+
- Country is auto-detected from the dial code
|
|
218
|
+
- `defaultCountry` parameter is optional (used for strict matching)
|
|
219
|
+
2. **0-prefixed**: `09876543210`
|
|
220
|
+
- **Requires** `defaultCountry` parameter (e.g., `validatePhoneNumber("09876543210", "IN")`)
|
|
221
|
+
3. **Plain digits**: `9876543210`
|
|
222
|
+
- **Requires** `defaultCountry` parameter (e.g., `validatePhoneNumber("9876543210", "IN")`)
|
|
185
223
|
|
|
186
224
|
## Country-Specific Validation
|
|
187
225
|
|
|
@@ -223,7 +261,7 @@ The package includes **comprehensive validation rules** for **50+ major countrie
|
|
|
223
261
|
|
|
224
262
|
#### Asia-Pacific
|
|
225
263
|
|
|
226
|
-
- **India (91)**: 10 digits (mobile: 6-9
|
|
264
|
+
- **India (91)**: 10 digits (mobile: 6-9) - Mobile prefix detection
|
|
227
265
|
- **China (86)**: 11 digits
|
|
228
266
|
- **Japan (81)**: 10-11 digits
|
|
229
267
|
- **South Korea (82)**: 9-10 digits
|
|
@@ -268,9 +306,9 @@ import { validatePhoneNumber } from "global-phone-validator";
|
|
|
268
306
|
validatePhoneNumber("+91 98765 43210");
|
|
269
307
|
// { isValid: true, isMobile: true, e164: '+919876543210', ... }
|
|
270
308
|
|
|
271
|
-
// Valid
|
|
272
|
-
validatePhoneNumber("
|
|
273
|
-
// { isValid: true,
|
|
309
|
+
// Valid German mobile number
|
|
310
|
+
validatePhoneNumber("+49 17677274194");
|
|
311
|
+
// { isValid: true, isMobile: true, e164: '+4917677274194', country: 'DE', ... }
|
|
274
312
|
|
|
275
313
|
// Invalid number
|
|
276
314
|
validatePhoneNumber("12345");
|
|
@@ -280,13 +318,13 @@ validatePhoneNumber("12345");
|
|
|
280
318
|
validatePhoneNumber("+1 555 123 4567");
|
|
281
319
|
// { isValid: true, country: 'US', e164: '+15551234567', ... }
|
|
282
320
|
|
|
283
|
-
// UK number
|
|
284
|
-
validatePhoneNumber("+44
|
|
285
|
-
// { isValid: true, country: 'GB', e164: '+
|
|
321
|
+
// UK mobile number
|
|
322
|
+
validatePhoneNumber("+44 7123 456789");
|
|
323
|
+
// { isValid: true, country: 'GB', isMobile: true, e164: '+447123456789', ... }
|
|
286
324
|
|
|
287
|
-
// Germany number
|
|
288
|
-
validatePhoneNumber("+49
|
|
289
|
-
// { isValid: true, country: 'DE', e164: '+
|
|
325
|
+
// Germany mobile number
|
|
326
|
+
validatePhoneNumber("+49 17677274194");
|
|
327
|
+
// { isValid: true, country: 'DE', isMobile: true, e164: '+4917677274194', ... }
|
|
290
328
|
|
|
291
329
|
// France number
|
|
292
330
|
validatePhoneNumber("+33 1 23 45 67 89");
|
|
@@ -307,6 +345,12 @@ validatePhoneNumber("+86 138 0013 8000");
|
|
|
307
345
|
// Japan number
|
|
308
346
|
validatePhoneNumber("+81 3 1234 5678");
|
|
309
347
|
// { isValid: true, country: 'JP', e164: '+81312345678', ... }
|
|
348
|
+
|
|
349
|
+
// Germany number with different spacing (all formats work)
|
|
350
|
+
validatePhoneNumber("+49 17677274194"); // With space after country code
|
|
351
|
+
validatePhoneNumber("+49 176 77274194"); // With spaces in number
|
|
352
|
+
validatePhoneNumber("+4917677274194"); // No spaces
|
|
353
|
+
// All produce: { isValid: true, country: 'DE', nationalNumber: '17677274194', e164: '+4917677274194', ... }
|
|
310
354
|
```
|
|
311
355
|
|
|
312
356
|
## Why Use This Package?
|
package/dist/index.d.ts
CHANGED
|
@@ -15,5 +15,5 @@ import { PhoneValidationResult } from "./types";
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function validatePhoneNumber(input: string, defaultCountry?: string, mobileOnly?: boolean): PhoneValidationResult;
|
|
17
17
|
export type { PhoneValidationResult, CountryCode } from "./types";
|
|
18
|
-
export { getAllCountryCodes, getCountryDialCode, getCountryCodeByDialCode } from "./utils";
|
|
18
|
+
export { getAllCountryCodes, getCountryDialCode, getCountryCodeByDialCode, } from "./utils";
|
|
19
19
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAe,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAe,MAAM,SAAS,CAAC;AAY7D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,cAAc,CAAC,EAAE,MAAM,EACvB,UAAU,GAAE,OAAe,GAC1B,qBAAqB,CA4LvB;AAGD,YAAY,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getCountryCodeByDialCode = exports.getCountryDialCode = exports.getAllCountryCodes = void 0;
|
|
7
7
|
exports.validatePhoneNumber = validatePhoneNumber;
|
|
8
8
|
const utils_1 = require("./utils");
|
|
9
|
+
const mobilePrefixes_1 = require("./mobilePrefixes");
|
|
9
10
|
const CountryCodes_json_1 = __importDefault(require("./CountryCodes.json"));
|
|
10
11
|
const COUNTRY_CODES = CountryCodes_json_1.default;
|
|
11
12
|
/**
|
|
@@ -22,7 +23,7 @@ const COUNTRY_CODES = CountryCodes_json_1.default;
|
|
|
22
23
|
* validatePhoneNumber("9876543210", "IN") // India plain digits
|
|
23
24
|
* validatePhoneNumber("+1 555 123 4567") // US number
|
|
24
25
|
*/
|
|
25
|
-
function validatePhoneNumber(input, defaultCountry
|
|
26
|
+
function validatePhoneNumber(input, defaultCountry, mobileOnly = false) {
|
|
26
27
|
if (!input || typeof input !== "string") {
|
|
27
28
|
return { isValid: false };
|
|
28
29
|
}
|
|
@@ -40,6 +41,13 @@ function validatePhoneNumber(input, defaultCountry = "IN", mobileOnly = false) {
|
|
|
40
41
|
detectedCountry = detection.country;
|
|
41
42
|
countryCode = detection.dialCode;
|
|
42
43
|
nationalNumber = detection.nationalNumber;
|
|
44
|
+
// If defaultCountry is provided, validate that detected country matches
|
|
45
|
+
if (defaultCountry) {
|
|
46
|
+
const expectedDialCode = (0, utils_1.getCountryDialCode)(defaultCountry);
|
|
47
|
+
if (expectedDialCode && countryCode !== expectedDialCode) {
|
|
48
|
+
return { isValid: false };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
43
51
|
}
|
|
44
52
|
else {
|
|
45
53
|
return { isValid: false };
|
|
@@ -47,23 +55,31 @@ function validatePhoneNumber(input, defaultCountry = "IN", mobileOnly = false) {
|
|
|
47
55
|
}
|
|
48
56
|
// Handle 0-prefixed numbers (common in many countries)
|
|
49
57
|
else if (cleaned.startsWith("0")) {
|
|
58
|
+
if (!defaultCountry) {
|
|
59
|
+
return { isValid: false }; // Require defaultCountry for 0-prefixed numbers
|
|
60
|
+
}
|
|
50
61
|
const defaultDialCode = (0, utils_1.getCountryDialCode)(defaultCountry);
|
|
51
62
|
if (!defaultDialCode) {
|
|
52
63
|
return { isValid: false };
|
|
53
64
|
}
|
|
54
65
|
countryCode = defaultDialCode;
|
|
55
66
|
nationalNumber = cleaned.substring(1);
|
|
56
|
-
detectedCountry =
|
|
67
|
+
detectedCountry =
|
|
68
|
+
COUNTRY_CODES.find((c) => c.code.toUpperCase() === defaultCountry.toUpperCase()) || null;
|
|
57
69
|
}
|
|
58
|
-
// Handle plain digits (
|
|
70
|
+
// Handle plain digits (require defaultCountry)
|
|
59
71
|
else {
|
|
72
|
+
if (!defaultCountry) {
|
|
73
|
+
return { isValid: false }; // Require defaultCountry for plain digits
|
|
74
|
+
}
|
|
60
75
|
const defaultDialCode = (0, utils_1.getCountryDialCode)(defaultCountry);
|
|
61
76
|
if (!defaultDialCode) {
|
|
62
77
|
return { isValid: false };
|
|
63
78
|
}
|
|
64
79
|
countryCode = defaultDialCode;
|
|
65
80
|
nationalNumber = cleaned;
|
|
66
|
-
detectedCountry =
|
|
81
|
+
detectedCountry =
|
|
82
|
+
COUNTRY_CODES.find((c) => c.code.toUpperCase() === defaultCountry.toUpperCase()) || null;
|
|
67
83
|
}
|
|
68
84
|
// Validate national number length (general rule: 4-15 digits)
|
|
69
85
|
if (nationalNumber.length < 4 || nationalNumber.length > 15) {
|
|
@@ -138,7 +154,8 @@ function validatePhoneNumber(input, defaultCountry = "IN", mobileOnly = false) {
|
|
|
138
154
|
const rule = validationRules[countryCode];
|
|
139
155
|
if (rule) {
|
|
140
156
|
// Use country-specific validation
|
|
141
|
-
if (nationalNumber.length < rule.minLength ||
|
|
157
|
+
if (nationalNumber.length < rule.minLength ||
|
|
158
|
+
nationalNumber.length > rule.maxLength) {
|
|
142
159
|
return { isValid: false };
|
|
143
160
|
}
|
|
144
161
|
if (!rule.pattern.test(nationalNumber)) {
|
|
@@ -151,25 +168,18 @@ function validatePhoneNumber(input, defaultCountry = "IN", mobileOnly = false) {
|
|
|
151
168
|
return { isValid: false };
|
|
152
169
|
}
|
|
153
170
|
}
|
|
154
|
-
// Mobile
|
|
171
|
+
// Mobile number detection (using country-specific prefix rules)
|
|
155
172
|
let isMobile;
|
|
156
|
-
|
|
157
|
-
if (
|
|
158
|
-
|
|
159
|
-
// Indian mobile numbers start with 6, 7, 8, or 9
|
|
160
|
-
if ("6789".includes(firstDigit)) {
|
|
161
|
-
isMobile = true;
|
|
162
|
-
isFixedLine = false;
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
// Landline numbers typically start with 0-5
|
|
166
|
-
isMobile = false;
|
|
167
|
-
isFixedLine = true;
|
|
168
|
-
}
|
|
173
|
+
const mobileCheck = (0, mobilePrefixes_1.isMobileNumber)(countryCode, nationalNumber);
|
|
174
|
+
if (mobileCheck !== undefined) {
|
|
175
|
+
isMobile = mobileCheck;
|
|
169
176
|
}
|
|
170
|
-
// If mobileOnly is true, fail non-mobile numbers
|
|
171
|
-
if (mobileOnly
|
|
172
|
-
|
|
177
|
+
// If mobileOnly is true, fail non-mobile numbers (works for all countries with mobile prefix rules)
|
|
178
|
+
if (mobileOnly) {
|
|
179
|
+
if (isMobile === false ||
|
|
180
|
+
(isMobile === undefined && mobileCheck === undefined)) {
|
|
181
|
+
return { isValid: false };
|
|
182
|
+
}
|
|
173
183
|
}
|
|
174
184
|
return {
|
|
175
185
|
isValid: true,
|
|
@@ -177,7 +187,6 @@ function validatePhoneNumber(input, defaultCountry = "IN", mobileOnly = false) {
|
|
|
177
187
|
nationalNumber,
|
|
178
188
|
e164: `+${countryCode}${nationalNumber}`,
|
|
179
189
|
isMobile,
|
|
180
|
-
isFixedLine,
|
|
181
190
|
country: detectedCountry?.code,
|
|
182
191
|
countryName: detectedCountry?.name,
|
|
183
192
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AA0BA,kDAgMC;AAzND,mCAKiB;AACjB,qDAAkD;AAClD,4EAA+C;AAE/C,MAAM,aAAa,GAAG,2BAA6B,CAAC;AAEpD;;;;;;;;;;;;;GAaG;AACH,SAAgB,mBAAmB,CACjC,KAAa,EACb,cAAuB,EACvB,aAAsB,KAAK;IAE3B,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED,MAAM,OAAO,GAAG,IAAA,wBAAgB,EAAC,KAAK,CAAC,CAAC;IAExC,IAAI,OAAO,CAAC,MAAM,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,UAAU,EAAE,CAAC;QACf,IACE,QAAQ,KAAK,KAAK;YAClB,CAAC,QAAQ,KAAK,SAAS,IAAI,WAAW,KAAK,SAAS,CAAC,EACrD,CAAC;YACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,WAAW;QACX,cAAc;QACd,IAAI,EAAE,IAAI,WAAW,GAAG,cAAc,EAAE;QACxC,QAAQ;QACR,OAAO,EAAE,eAAe,EAAE,IAAI;QAC9B,WAAW,EAAE,eAAe,EAAE,IAAI;KACnC,CAAC;AACJ,CAAC;AAID,iCAIiB;AAHf,2GAAA,kBAAkB,OAAA;AAClB,2GAAA,kBAAkB,OAAA;AAClB,iHAAA,wBAAwB,OAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mobile number prefix rules for countries
|
|
3
|
+
* Format: { countryCode: { mobilePrefixes: string[], landlinePrefixes?: string[] } }
|
|
4
|
+
*/
|
|
5
|
+
export interface MobilePrefixRules {
|
|
6
|
+
mobilePrefixes: string[];
|
|
7
|
+
landlinePrefixes?: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare const MOBILE_PREFIX_RULES: Record<string, MobilePrefixRules>;
|
|
10
|
+
/**
|
|
11
|
+
* Check if a number is a mobile number based on country-specific prefix rules
|
|
12
|
+
*/
|
|
13
|
+
export declare function isMobileNumber(countryCode: string, nationalNumber: string): boolean | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Check if a number is a landline number based on country-specific prefix rules
|
|
16
|
+
*/
|
|
17
|
+
export declare function isLandlineNumber(countryCode: string, nationalNumber: string): boolean | undefined;
|
|
18
|
+
//# sourceMappingURL=mobilePrefixes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mobilePrefixes.d.ts","sourceRoot":"","sources":["../src/mobilePrefixes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAgMjE,CAAC;AAEF;;GAEG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,GACrB,OAAO,GAAG,SAAS,CAyBrB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,GACrB,OAAO,GAAG,SAAS,CA8BrB"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Mobile number prefix rules for countries
|
|
4
|
+
* Format: { countryCode: { mobilePrefixes: string[], landlinePrefixes?: string[] } }
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.MOBILE_PREFIX_RULES = void 0;
|
|
8
|
+
exports.isMobileNumber = isMobileNumber;
|
|
9
|
+
exports.isLandlineNumber = isLandlineNumber;
|
|
10
|
+
exports.MOBILE_PREFIX_RULES = {
|
|
11
|
+
// India (91)
|
|
12
|
+
"91": {
|
|
13
|
+
mobilePrefixes: ["6", "7", "8", "9"],
|
|
14
|
+
landlinePrefixes: ["0", "1", "2", "3", "4", "5"],
|
|
15
|
+
},
|
|
16
|
+
// Germany (49)
|
|
17
|
+
"49": {
|
|
18
|
+
mobilePrefixes: ["15", "16", "17"],
|
|
19
|
+
landlinePrefixes: ["30", "40", "69", "89", "211", "221", "231", "241", "351", "361", "371", "381", "391", "421", "431", "451", "461", "471", "481", "511", "531", "541", "561", "571", "581", "591", "611", "621", "631", "641", "651", "661", "671", "681", "691", "711", "721", "731", "741", "751", "761", "771", "781", "911", "921", "931", "941", "951", "961", "971", "981", "991"],
|
|
20
|
+
},
|
|
21
|
+
// United States/Canada (1)
|
|
22
|
+
"1": {
|
|
23
|
+
mobilePrefixes: [], // All 10-digit numbers can be mobile or landline
|
|
24
|
+
landlinePrefixes: [],
|
|
25
|
+
},
|
|
26
|
+
// United Kingdom (44)
|
|
27
|
+
"44": {
|
|
28
|
+
mobilePrefixes: ["7"], // Mobile numbers start with 7
|
|
29
|
+
landlinePrefixes: ["1", "2", "3", "4", "5", "6", "8", "9"],
|
|
30
|
+
},
|
|
31
|
+
// France (33)
|
|
32
|
+
"33": {
|
|
33
|
+
mobilePrefixes: ["6", "7"], // Mobile numbers start with 6 or 7
|
|
34
|
+
landlinePrefixes: ["1", "2", "3", "4", "5", "8", "9"],
|
|
35
|
+
},
|
|
36
|
+
// Italy (39)
|
|
37
|
+
"39": {
|
|
38
|
+
mobilePrefixes: ["3"], // Mobile numbers start with 3
|
|
39
|
+
landlinePrefixes: ["0", "1", "2", "4", "5", "6", "7", "8", "9"],
|
|
40
|
+
},
|
|
41
|
+
// Spain (34)
|
|
42
|
+
"34": {
|
|
43
|
+
mobilePrefixes: ["6", "7"], // Mobile numbers start with 6 or 7
|
|
44
|
+
landlinePrefixes: ["8", "9"],
|
|
45
|
+
},
|
|
46
|
+
// Australia (61)
|
|
47
|
+
"61": {
|
|
48
|
+
mobilePrefixes: ["4"], // Mobile numbers start with 4
|
|
49
|
+
landlinePrefixes: ["2", "3", "7", "8"],
|
|
50
|
+
},
|
|
51
|
+
// Brazil (55)
|
|
52
|
+
"55": {
|
|
53
|
+
mobilePrefixes: ["9"], // Mobile numbers start with 9 (after area code)
|
|
54
|
+
landlinePrefixes: ["1", "2", "3", "4", "5", "6", "7", "8"],
|
|
55
|
+
},
|
|
56
|
+
// China (86)
|
|
57
|
+
"86": {
|
|
58
|
+
mobilePrefixes: ["13", "14", "15", "16", "17", "18", "19"], // Mobile numbers start with 13x-19x
|
|
59
|
+
landlinePrefixes: ["10", "20", "21", "22", "23", "24", "25", "27", "28", "29", "311", "351", "371", "431", "451", "471", "531", "551", "571", "591", "631", "671", "731", "751", "771", "791", "851", "871", "891", "898", "931", "951", "971", "991"],
|
|
60
|
+
},
|
|
61
|
+
// Japan (81)
|
|
62
|
+
"81": {
|
|
63
|
+
mobilePrefixes: ["70", "80", "90"], // Mobile numbers start with 70, 80, or 90
|
|
64
|
+
landlinePrefixes: ["3", "6", "11", "52", "92", "93", "95", "96", "98"],
|
|
65
|
+
},
|
|
66
|
+
// South Korea (82)
|
|
67
|
+
"82": {
|
|
68
|
+
mobilePrefixes: ["10", "11", "16", "17", "18", "19"], // Mobile numbers start with 10x-19x
|
|
69
|
+
landlinePrefixes: ["2", "31", "32", "33", "41", "42", "43", "44", "51", "52", "53", "54", "55", "61", "62", "63", "64"],
|
|
70
|
+
},
|
|
71
|
+
// Russia (7)
|
|
72
|
+
"7": {
|
|
73
|
+
mobilePrefixes: ["9"], // Mobile numbers start with 9
|
|
74
|
+
landlinePrefixes: ["3", "4", "5", "8"],
|
|
75
|
+
},
|
|
76
|
+
// Netherlands (31)
|
|
77
|
+
"31": {
|
|
78
|
+
mobilePrefixes: ["6"], // Mobile numbers start with 6
|
|
79
|
+
landlinePrefixes: ["1", "2", "3", "4", "5", "7", "8", "9"],
|
|
80
|
+
},
|
|
81
|
+
// Sweden (46)
|
|
82
|
+
"46": {
|
|
83
|
+
mobilePrefixes: ["7"], // Mobile numbers start with 7
|
|
84
|
+
landlinePrefixes: ["8", "11", "13", "16", "18", "19", "21", "23", "26", "31", "33", "35", "36", "40", "42", "44", "46", "54", "60", "63", "90"],
|
|
85
|
+
},
|
|
86
|
+
// Norway (47)
|
|
87
|
+
"47": {
|
|
88
|
+
mobilePrefixes: ["4", "9"], // Mobile numbers start with 4 or 9
|
|
89
|
+
landlinePrefixes: ["2", "3", "5", "6", "7", "8"],
|
|
90
|
+
},
|
|
91
|
+
// Poland (48)
|
|
92
|
+
"48": {
|
|
93
|
+
mobilePrefixes: ["5", "6", "7", "8", "9"], // Mobile numbers start with 5-9
|
|
94
|
+
landlinePrefixes: ["1", "2", "3", "4"],
|
|
95
|
+
},
|
|
96
|
+
// Turkey (90)
|
|
97
|
+
"90": {
|
|
98
|
+
mobilePrefixes: ["5"], // Mobile numbers start with 5
|
|
99
|
+
landlinePrefixes: ["2", "3", "4"],
|
|
100
|
+
},
|
|
101
|
+
// Pakistan (92)
|
|
102
|
+
"92": {
|
|
103
|
+
mobilePrefixes: ["3"], // Mobile numbers start with 3
|
|
104
|
+
landlinePrefixes: ["4", "5", "6", "7", "8", "9"],
|
|
105
|
+
},
|
|
106
|
+
// Indonesia (62)
|
|
107
|
+
"62": {
|
|
108
|
+
mobilePrefixes: ["8"], // Mobile numbers start with 8
|
|
109
|
+
landlinePrefixes: ["2", "3", "4", "5", "6", "7", "9"],
|
|
110
|
+
},
|
|
111
|
+
// Philippines (63)
|
|
112
|
+
"63": {
|
|
113
|
+
mobilePrefixes: ["9"], // Mobile numbers start with 9
|
|
114
|
+
landlinePrefixes: ["2", "3", "4", "5", "6", "7", "8"],
|
|
115
|
+
},
|
|
116
|
+
// Thailand (66)
|
|
117
|
+
"66": {
|
|
118
|
+
mobilePrefixes: ["6", "8", "9"], // Mobile numbers start with 6, 8, or 9
|
|
119
|
+
landlinePrefixes: ["2", "3", "4", "5", "7"],
|
|
120
|
+
},
|
|
121
|
+
// Malaysia (60)
|
|
122
|
+
"60": {
|
|
123
|
+
mobilePrefixes: ["1"], // Mobile numbers start with 1
|
|
124
|
+
landlinePrefixes: ["3", "4", "5", "6", "7", "9"],
|
|
125
|
+
},
|
|
126
|
+
// Singapore (65)
|
|
127
|
+
"65": {
|
|
128
|
+
mobilePrefixes: ["8", "9"], // Mobile numbers start with 8 or 9
|
|
129
|
+
landlinePrefixes: ["6"],
|
|
130
|
+
},
|
|
131
|
+
// New Zealand (64)
|
|
132
|
+
"64": {
|
|
133
|
+
mobilePrefixes: ["2"], // Mobile numbers start with 2
|
|
134
|
+
landlinePrefixes: ["3", "4", "6", "7", "9"],
|
|
135
|
+
},
|
|
136
|
+
// Vietnam (84)
|
|
137
|
+
"84": {
|
|
138
|
+
mobilePrefixes: ["9"], // Mobile numbers start with 9
|
|
139
|
+
landlinePrefixes: ["2", "3", "4", "5", "6", "7", "8"],
|
|
140
|
+
},
|
|
141
|
+
// UAE (971)
|
|
142
|
+
"971": {
|
|
143
|
+
mobilePrefixes: ["5"], // Mobile numbers start with 5
|
|
144
|
+
landlinePrefixes: ["2", "3", "4", "6", "7", "9"],
|
|
145
|
+
},
|
|
146
|
+
// South Africa (27)
|
|
147
|
+
"27": {
|
|
148
|
+
mobilePrefixes: ["6", "7", "8"], // Mobile numbers start with 6, 7, or 8
|
|
149
|
+
landlinePrefixes: ["1", "2", "3", "4", "5", "9"],
|
|
150
|
+
},
|
|
151
|
+
// Nigeria (234)
|
|
152
|
+
"234": {
|
|
153
|
+
mobilePrefixes: ["7", "8", "9"], // Mobile numbers start with 7, 8, or 9
|
|
154
|
+
landlinePrefixes: ["1", "2", "3", "4", "5", "6"],
|
|
155
|
+
},
|
|
156
|
+
// Mexico (52)
|
|
157
|
+
"52": {
|
|
158
|
+
mobilePrefixes: ["1"], // Mobile numbers start with 1 (after area code)
|
|
159
|
+
landlinePrefixes: ["2", "3", "4", "5", "6", "7", "8", "9"],
|
|
160
|
+
},
|
|
161
|
+
// Argentina (54)
|
|
162
|
+
"54": {
|
|
163
|
+
mobilePrefixes: ["9"], // Mobile numbers start with 9
|
|
164
|
+
landlinePrefixes: ["1", "2", "3", "4", "5", "6", "7", "8"],
|
|
165
|
+
},
|
|
166
|
+
// Colombia (57)
|
|
167
|
+
"57": {
|
|
168
|
+
mobilePrefixes: ["3"], // Mobile numbers start with 3
|
|
169
|
+
landlinePrefixes: ["1", "2", "4", "5", "6", "7", "8", "9"],
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Check if a number is a mobile number based on country-specific prefix rules
|
|
174
|
+
*/
|
|
175
|
+
function isMobileNumber(countryCode, nationalNumber) {
|
|
176
|
+
const rules = exports.MOBILE_PREFIX_RULES[countryCode];
|
|
177
|
+
if (!rules || rules.mobilePrefixes.length === 0) {
|
|
178
|
+
return undefined; // No rules available
|
|
179
|
+
}
|
|
180
|
+
// Check if number starts with any mobile prefix
|
|
181
|
+
for (const prefix of rules.mobilePrefixes) {
|
|
182
|
+
if (nationalNumber.startsWith(prefix)) {
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// If landline prefixes are defined and number matches, it's a landline
|
|
187
|
+
if (rules.landlinePrefixes && rules.landlinePrefixes.length > 0) {
|
|
188
|
+
for (const prefix of rules.landlinePrefixes) {
|
|
189
|
+
if (nationalNumber.startsWith(prefix)) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
// If we have mobile prefixes but number doesn't match, it might be invalid
|
|
195
|
+
// Return undefined to let other validation handle it
|
|
196
|
+
return undefined;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Check if a number is a landline number based on country-specific prefix rules
|
|
200
|
+
*/
|
|
201
|
+
function isLandlineNumber(countryCode, nationalNumber) {
|
|
202
|
+
const rules = exports.MOBILE_PREFIX_RULES[countryCode];
|
|
203
|
+
if (!rules) {
|
|
204
|
+
return undefined;
|
|
205
|
+
}
|
|
206
|
+
// If landline prefixes are defined, check them
|
|
207
|
+
if (rules.landlinePrefixes && rules.landlinePrefixes.length > 0) {
|
|
208
|
+
for (const prefix of rules.landlinePrefixes) {
|
|
209
|
+
if (nationalNumber.startsWith(prefix)) {
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
// If mobile prefixes are defined and number doesn't match mobile, might be landline
|
|
215
|
+
if (rules.mobilePrefixes.length > 0) {
|
|
216
|
+
let matchesMobile = false;
|
|
217
|
+
for (const prefix of rules.mobilePrefixes) {
|
|
218
|
+
if (nationalNumber.startsWith(prefix)) {
|
|
219
|
+
matchesMobile = true;
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (!matchesMobile) {
|
|
224
|
+
return true; // Not mobile, likely landline
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return undefined;
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=mobilePrefixes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mobilePrefixes.js","sourceRoot":"","sources":["../src/mobilePrefixes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA4MH,wCA4BC;AAKD,4CAiCC;AAvQY,QAAA,mBAAmB,GAAsC;IACpE,aAAa;IACb,IAAI,EAAE;QACJ,cAAc,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;QACpC,gBAAgB,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;KACjD;IAED,eAAe;IACf,IAAI,EAAE;QACJ,cAAc,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;QAClC,gBAAgB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,K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nB,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAC9B,WAAmB,EACnB,cAAsB;IAEtB,MAAM,KAAK,GAAG,2BAAmB,CAAC,WAAW,CAAC,CAAC;IAC/C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,+CAA+C;IAC/C,IAAI,KAAK,CAAC,gBAAgB,IAAI,KAAK,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChE,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,gBAAgB,EAAE,CAAC;YAC5C,IAAI,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;gBACtC,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IAED,oFAAoF;IACpF,IAAI,KAAK,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpC,IAAI,aAAa,GAAG,KAAK,CAAC;QAC1B,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;YAC1C,IAAI,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;gBACtC,aAAa,GAAG,IAAI,CAAC;gBACrB,MAAM;YACR,CAAC;QACH,CAAC;QACD,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC,CAAC,8BAA8B;QAC7C,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/types.d.ts
CHANGED
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "global-phone-validator",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "A reusable Node.js + TypeScript package for validating phone numbers worldwide. Supports
|
|
3
|
+
"version": "1.2.1",
|
|
4
|
+
"description": "A reusable Node.js + TypeScript package for validating mobile phone numbers worldwide. Supports all countries with country-specific validation rules and mobile prefix detection for 50+ major countries. Handles international formats (+CC), 0-prefixed, and plain digits. Returns standardized E.164 format.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -26,12 +26,11 @@
|
|
|
26
26
|
"validator",
|
|
27
27
|
"validation",
|
|
28
28
|
"mobile",
|
|
29
|
-
"
|
|
29
|
+
"mobile-phone",
|
|
30
30
|
"international",
|
|
31
31
|
"E164",
|
|
32
32
|
"E.164",
|
|
33
33
|
"country-code",
|
|
34
|
-
"india",
|
|
35
34
|
"worldwide",
|
|
36
35
|
"typescript"
|
|
37
36
|
],
|