libphonenumber-js 1.10.44 → 1.10.46

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.
@@ -11,10 +11,11 @@ var NON_FIXED_LINE_PHONE_TYPES = ['MOBILE', 'PREMIUM_RATE', 'TOLL_FREE', 'SHARED
11
11
  export default function getNumberType(input, options, metadata) {
12
12
  // If assigning the `{}` default value is moved to the arguments above,
13
13
  // code coverage would decrease for some weird reason.
14
- options = options || {}; // When `parse()` returned `{}`
15
- // meaning that the phone number is not a valid one.
14
+ options = options || {}; // When `parse()` returns an empty object — `{}` —
15
+ // that means that the phone number is malformed,
16
+ // so it can't possibly be valid.
16
17
 
17
- if (!input.country) {
18
+ if (!input.country && !input.countryCallingCode) {
18
19
  return;
19
20
  }
20
21
 
@@ -1 +1 @@
1
- {"version":3,"file":"getNumberType.js","names":["Metadata","matchesEntirely","NON_FIXED_LINE_PHONE_TYPES","getNumberType","input","options","metadata","country","selectNumberingPlan","countryCallingCode","nationalNumber","v2","phone","nationalNumberPattern","isNumberTypeEqualTo","type","pattern","possibleLengths","indexOf","length"],"sources":["../../source/helpers/getNumberType.js"],"sourcesContent":["import Metadata from '../metadata.js'\r\nimport matchesEntirely from './matchesEntirely.js'\r\n\r\nconst NON_FIXED_LINE_PHONE_TYPES = [\r\n\t'MOBILE',\r\n\t'PREMIUM_RATE',\r\n\t'TOLL_FREE',\r\n\t'SHARED_COST',\r\n\t'VOIP',\r\n\t'PERSONAL_NUMBER',\r\n\t'PAGER',\r\n\t'UAN',\r\n\t'VOICEMAIL'\r\n]\r\n\r\n// Finds out national phone number type (fixed line, mobile, etc)\r\nexport default function getNumberType(input, options, metadata)\r\n{\r\n\t// If assigning the `{}` default value is moved to the arguments above,\r\n\t// code coverage would decrease for some weird reason.\r\n\toptions = options || {}\r\n\r\n\t// When `parse()` returned `{}`\r\n\t// meaning that the phone number is not a valid one.\r\n\tif (!input.country) {\r\n\t\treturn\r\n\t}\r\n\r\n\tmetadata = new Metadata(metadata)\r\n\r\n\tmetadata.selectNumberingPlan(input.country, input.countryCallingCode)\r\n\r\n\tconst nationalNumber = options.v2 ? input.nationalNumber : input.phone\r\n\r\n\t// The following is copy-pasted from the original function:\r\n\t// https://github.com/googlei18n/libphonenumber/blob/3ea547d4fbaa2d0b67588904dfa5d3f2557c27ff/javascript/i18n/phonenumbers/phonenumberutil.js#L2835\r\n\r\n\t// Is this national number even valid for this country\r\n\tif (!matchesEntirely(nationalNumber, metadata.nationalNumberPattern())) {\r\n\t\treturn\r\n\t}\r\n\r\n\t// Is it fixed line number\r\n\tif (isNumberTypeEqualTo(nationalNumber, 'FIXED_LINE', metadata)) {\r\n\t\t// Because duplicate regular expressions are removed\r\n\t\t// to reduce metadata size, if \"mobile\" pattern is \"\"\r\n\t\t// then it means it was removed due to being a duplicate of the fixed-line pattern.\r\n\t\t//\r\n\t\tif (metadata.type('MOBILE') && metadata.type('MOBILE').pattern() === '') {\r\n\t\t\treturn 'FIXED_LINE_OR_MOBILE'\r\n\t\t}\r\n\r\n\t\t// `MOBILE` type pattern isn't included if it matched `FIXED_LINE` one.\r\n\t\t// For example, for \"US\" country.\r\n\t\t// Old metadata (< `1.0.18`) had a specific \"types\" data structure\r\n\t\t// that happened to be `undefined` for `MOBILE` in that case.\r\n\t\t// Newer metadata (>= `1.0.18`) has another data structure that is\r\n\t\t// not `undefined` for `MOBILE` in that case (it's just an empty array).\r\n\t\t// So this `if` is just for backwards compatibility with old metadata.\r\n\t\tif (!metadata.type('MOBILE')) {\r\n\t\t\treturn 'FIXED_LINE_OR_MOBILE'\r\n\t\t}\r\n\r\n\t\t// Check if the number happens to qualify as both fixed line and mobile.\r\n\t\t// (no such country in the minimal metadata set)\r\n\t\t/* istanbul ignore if */\r\n\t\tif (isNumberTypeEqualTo(nationalNumber, 'MOBILE', metadata)) {\r\n\t\t\treturn 'FIXED_LINE_OR_MOBILE'\r\n\t\t}\r\n\r\n\t\treturn 'FIXED_LINE'\r\n\t}\r\n\r\n\tfor (const type of NON_FIXED_LINE_PHONE_TYPES) {\r\n\t\tif (isNumberTypeEqualTo(nationalNumber, type, metadata)) {\r\n\t\t\treturn type\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport function isNumberTypeEqualTo(nationalNumber, type, metadata) {\r\n\ttype = metadata.type(type)\r\n\tif (!type || !type.pattern()) {\r\n\t\treturn false\r\n\t}\r\n\t// Check if any possible number lengths are present;\r\n\t// if so, we use them to avoid checking\r\n\t// the validation pattern if they don't match.\r\n\t// If they are absent, this means they match\r\n\t// the general description, which we have\r\n\t// already checked before a specific number type.\r\n\tif (type.possibleLengths() &&\r\n\t\ttype.possibleLengths().indexOf(nationalNumber.length) < 0) {\r\n\t\treturn false\r\n\t}\r\n\treturn matchesEntirely(nationalNumber, type.pattern())\r\n}"],"mappings":";;;;;;AAAA,OAAOA,QAAP,MAAqB,gBAArB;AACA,OAAOC,eAAP,MAA4B,sBAA5B;AAEA,IAAMC,0BAA0B,GAAG,CAClC,QADkC,EAElC,cAFkC,EAGlC,WAHkC,EAIlC,aAJkC,EAKlC,MALkC,EAMlC,iBANkC,EAOlC,OAPkC,EAQlC,KARkC,EASlC,WATkC,CAAnC,C,CAYA;;AACA,eAAe,SAASC,aAAT,CAAuBC,KAAvB,EAA8BC,OAA9B,EAAuCC,QAAvC,EACf;EACC;EACA;EACAD,OAAO,GAAGA,OAAO,IAAI,EAArB,CAHD,CAKC;EACA;;EACA,IAAI,CAACD,KAAK,CAACG,OAAX,EAAoB;IACnB;EACA;;EAEDD,QAAQ,GAAG,IAAIN,QAAJ,CAAaM,QAAb,CAAX;EAEAA,QAAQ,CAACE,mBAAT,CAA6BJ,KAAK,CAACG,OAAnC,EAA4CH,KAAK,CAACK,kBAAlD;EAEA,IAAMC,cAAc,GAAGL,OAAO,CAACM,EAAR,GAAaP,KAAK,CAACM,cAAnB,GAAoCN,KAAK,CAACQ,KAAjE,CAfD,CAiBC;EACA;EAEA;;EACA,IAAI,CAACX,eA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AAD,EAAiBK,IAAI,CAACC,OAAL,EAAjB,CAAtB;AACA"}
1
+ {"version":3,"file":"getNumberType.js","names":["Metadata","matchesEntirely","NON_FIXED_LINE_PHONE_TYPES","getNumberType","input","options","metadata","country","countryCallingCode","selectNumberingPlan","nationalNumber","v2","phone","nationalNumberPattern","isNumberTypeEqualTo","type","pattern","possibleLengths","indexOf","length"],"sources":["../../source/helpers/getNumberType.js"],"sourcesContent":["import Metadata from '../metadata.js'\r\nimport matchesEntirely from './matchesEntirely.js'\r\n\r\nconst NON_FIXED_LINE_PHONE_TYPES = [\r\n\t'MOBILE',\r\n\t'PREMIUM_RATE',\r\n\t'TOLL_FREE',\r\n\t'SHARED_COST',\r\n\t'VOIP',\r\n\t'PERSONAL_NUMBER',\r\n\t'PAGER',\r\n\t'UAN',\r\n\t'VOICEMAIL'\r\n]\r\n\r\n// Finds out national phone number type (fixed line, mobile, etc)\r\nexport default function getNumberType(input, options, metadata)\r\n{\r\n\t// If assigning the `{}` default value is moved to the arguments above,\r\n\t// code coverage would decrease for some weird reason.\r\n\toptions = options || {}\r\n\r\n\t// When `parse()` returns an empty object — `{}` —\r\n\t// that means that the phone number is malformed,\r\n\t// so it can't possibly be valid.\r\n\tif (!input.country && !input.countryCallingCode) {\r\n\t\treturn\r\n\t}\r\n\r\n\tmetadata = new Metadata(metadata)\r\n\r\n\tmetadata.selectNumberingPlan(input.country, input.countryCallingCode)\r\n\r\n\tconst nationalNumber = options.v2 ? input.nationalNumber : input.phone\r\n\r\n\t// The following is copy-pasted from the original function:\r\n\t// https://github.com/googlei18n/libphonenumber/blob/3ea547d4fbaa2d0b67588904dfa5d3f2557c27ff/javascript/i18n/phonenumbers/phonenumberutil.js#L2835\r\n\r\n\t// Is this national number even valid for this country\r\n\tif (!matchesEntirely(nationalNumber, metadata.nationalNumberPattern())) {\r\n\t\treturn\r\n\t}\r\n\r\n\t// Is it fixed line number\r\n\tif (isNumberTypeEqualTo(nationalNumber, 'FIXED_LINE', metadata)) {\r\n\t\t// Because duplicate regular expressions are removed\r\n\t\t// to reduce metadata size, if \"mobile\" pattern is \"\"\r\n\t\t// then it means it was removed due to being a duplicate of the fixed-line pattern.\r\n\t\t//\r\n\t\tif (metadata.type('MOBILE') && metadata.type('MOBILE').pattern() === '') {\r\n\t\t\treturn 'FIXED_LINE_OR_MOBILE'\r\n\t\t}\r\n\r\n\t\t// `MOBILE` type pattern isn't included if it matched `FIXED_LINE` one.\r\n\t\t// For example, for \"US\" country.\r\n\t\t// Old metadata (< `1.0.18`) had a specific \"types\" data structure\r\n\t\t// that happened to be `undefined` for `MOBILE` in that case.\r\n\t\t// Newer metadata (>= `1.0.18`) has another data structure that is\r\n\t\t// not `undefined` for `MOBILE` in that case (it's just an empty array).\r\n\t\t// So this `if` is just for backwards compatibility with old metadata.\r\n\t\tif (!metadata.type('MOBILE')) {\r\n\t\t\treturn 'FIXED_LINE_OR_MOBILE'\r\n\t\t}\r\n\r\n\t\t// Check if the number happens to qualify as both fixed line and mobile.\r\n\t\t// (no such country in the minimal metadata set)\r\n\t\t/* istanbul ignore if */\r\n\t\tif (isNumberTypeEqualTo(nationalNumber, 'MOBILE', metadata)) {\r\n\t\t\treturn 'FIXED_LINE_OR_MOBILE'\r\n\t\t}\r\n\r\n\t\treturn 'FIXED_LINE'\r\n\t}\r\n\r\n\tfor (const type of NON_FIXED_LINE_PHONE_TYPES) {\r\n\t\tif (isNumberTypeEqualTo(nationalNumber, type, metadata)) {\r\n\t\t\treturn type\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport function isNumberTypeEqualTo(nationalNumber, type, metadata) {\r\n\ttype = metadata.type(type)\r\n\tif (!type || !type.pattern()) {\r\n\t\treturn false\r\n\t}\r\n\t// Check if any possible number lengths are present;\r\n\t// if so, we use them to avoid checking\r\n\t// the validation pattern if they don't match.\r\n\t// If they are absent, this means they match\r\n\t// the general description, which we have\r\n\t// already checked before a specific number type.\r\n\tif (type.possibleLengths() &&\r\n\t\ttype.possibleLengths().indexOf(nationalNumber.length) < 0) {\r\n\t\treturn false\r\n\t}\r\n\treturn matchesEntirely(nationalNumber, type.pattern())\r\n}"],"mappings":";;;;;;AAAA,OAAOA,QAAP,MAAqB,gBAArB;AACA,OAAOC,eAAP,MAA4B,sBAA5B;AAEA,IAAMC,0BAA0B,GAAG,CAClC,QADkC,EAElC,cAFkC,EAGlC,WAHkC,EAIlC,aAJkC,EAKlC,MALkC,EAMlC,iBANkC,EAOlC,OAPkC,EAQlC,KARkC,EASlC,WATkC,CAAnC,C,CAYA;;AACA,eAAe,SAASC,aAAT,CAAuBC,KAAvB,EAA8BC,OAA9B,EAAuCC,QAAvC,EACf;EACC;EACA;EACAD,OAAO,GAAGA,OAAO,IAAI,EAArB,CAHD,CAKC;EACA;EACA;;EACA,IAAI,CAACD,KAAK,CAACG,OAAP,IAAkB,CAACH,KAAK,CAACI,kBAA7B,EAAiD;IAChD;EACA;;EAEDF,QAAQ,GAAG,IAAIN,QAAJ,CAAaM,QAAb,CAAX;EAEAA,QAAQ,CAACG,mBAAT,CAA6BL,KAAK,CAACG,OAAnC,EAA4CH,KAAK,CAACI,kBAAlD;EAEA,IAAME,cAAc,GAAGL,OAAO,CAACM,EAAR,GAAaP,KAAK,CAACM,cAAnB,GAAoCN,KAAK,CAACQ,KAAjE,CAhBD,CAkBC;EACA;EAEA;;EACA,IAAI,CAACX,eAAe,CAACS,cAAD,EAAiBJ,QAAQ,CAACO,qBAAT,EAAjB,CAApB,EAAwE;IACvE;EACA,CAxBF,CA0BC;;;EACA,IAAIC,mBAAmB,CAACJ,cAAD,EAAiB,YAAjB,EAA+BJ,QAA/B,CAAvB,EAAiE;IAChE;IACA;IACA;IACA;IACA,IAAIA,QAAQ,CAACS,IAAT,CAAc,QAAd,KAA2BT,QAAQ,CAACS,IAAT,CAAc,QAAd,EAAwBC,OAAxB,OAAsC,EAArE,EAAyE;MACxE,OAAO,sBAAP;IACA,CAP+D,CAShE;IACA;IACA;IACA;IACA;IACA;IACA;;;IACA,IAAI,CAACV,QAAQ,CAACS,IAAT,CAAc,QAAd,CAAL,EAA8B;MAC7B,OAAO,sBAAP;IACA,CAlB+D,CAoBhE;IACA;;IACA;;;IACA,IAAID,mBAAmB,CAACJ,cAAD,EAAiB,QAAjB,EAA2BJ,QAA3B,CAAvB,EAA6D;MAC5D,OAAO,sBAAP;IACA;;IAED,OAAO,YAAP;EACA;;EAED,qDAAmBJ,0BAAnB,wCAA+C;IAAA,IAApCa,IAAoC;;IAC9C,IAAID,mBAAmB,CAACJ,cAAD,EAAiBK,IAAjB,EAAuBT,QAAvB,CAAvB,EAAyD;MACxD,OAAOS,IAAP;IACA;EACD;AACD;AAED,OAAO,SAASD,mBAAT,CAA6BJ,cAA7B,EAA6CK,IAA7C,EAAmDT,QAAnD,EAA6D;EACnES,IAAI,GAAGT,QAAQ,CAACS,IAAT,CAAcA,IAAd,CAAP;;EACA,IAAI,CAACA,IAAD,IAAS,CAACA,IAAI,CAACC,OAAL,EAAd,EAA8B;IAC7B,OAAO,KAAP;EACA,CAJkE,CAKnE;EACA;EACA;EACA;EACA;EACA;;;EACA,IAAID,IAAI,CAACE,eAAL,MACHF,IAAI,CAACE,eAAL,GAAuBC,OAAvB,CAA+BR,cAAc,CAACS,MAA9C,IAAwD,CADzD,EAC4D;IAC3D,OAAO,KAAP;EACA;;EACD,OAAOlB,eAAe,CAACS,cAAD,EAAiBK,IAAI,CAACC,OAAL,EAAjB,CAAtB;AACA"}
@@ -10,5 +10,10 @@ describe('getNumberType', function () {
10
10
  v2: true
11
11
  }, oldMetadata).should.equal('FIXED_LINE_OR_MOBILE');
12
12
  });
13
+ it('should return `undefined` when the phone number is a malformed one', function () {
14
+ expect(getNumberType({}, {
15
+ v2: true
16
+ }, oldMetadata)).to.equal(undefined);
17
+ });
13
18
  });
14
19
  //# sourceMappingURL=getNumberType.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getNumberType.test.js","names":["getNumberType","oldMetadata","type","Metadata","describe","it","nationalNumber","country","v2","should","equal"],"sources":["../../source/helpers/getNumberType.test.js"],"sourcesContent":["import getNumberType from './getNumberType.js'\r\n\r\nimport oldMetadata from '../../test/metadata/1.0.0/metadata.min.json' assert { type: 'json' }\r\n\r\nimport Metadata from '../metadata.js'\r\n\r\ndescribe('getNumberType', function() {\r\n\tit('should get number type when using old metadata', function() {\r\n\t\tgetNumberType(\r\n\t\t\t{\r\n\t\t\t\tnationalNumber: '2133734253',\r\n\t\t\t\tcountry: 'US'\r\n\t\t\t},\r\n\t\t\t{ v2: true },\r\n\t\t\toldMetadata\r\n\t\t).should.equal('FIXED_LINE_OR_MOBILE')\r\n\t})\r\n})"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,oBAA1B;AAEA,OAAOC,WAAP,MAAwB,6CAAxB,UAA+EC,IAAI,EAAE,MAArF;AAEA,OAAOC,QAAP,MAAqB,gBAArB;AAEAC,QAAQ,CAAC,eAAD,EAAkB,YAAW;EACpCC,EAAE,CAAC,gDAAD,EAAmD,YAAW;IAC/DL,aAAa,CACZ;MACCM,cAAc,EAAE,YADjB;MAECC,OAAO,EAAE;IAFV,CADY,EAKZ;MAAEC,EAAE,EAAE;IAAN,CALY,EAMZP,WANY,CAAb,CAOEQ,MAPF,CAOSC,KAPT,CAOe,sBAPf;EAQA,CATC,CAAF;AAUA,CAXO,CAAR"}
1
+ {"version":3,"file":"getNumberType.test.js","names":["getNumberType","oldMetadata","type","Metadata","describe","it","nationalNumber","country","v2","should","equal","expect","to","undefined"],"sources":["../../source/helpers/getNumberType.test.js"],"sourcesContent":["import getNumberType from './getNumberType.js'\r\n\r\nimport oldMetadata from '../../test/metadata/1.0.0/metadata.min.json' assert { type: 'json' }\r\n\r\nimport Metadata from '../metadata.js'\r\n\r\ndescribe('getNumberType', function() {\r\n\tit('should get number type when using old metadata', function() {\r\n\t\tgetNumberType(\r\n\t\t\t{\r\n\t\t\t\tnationalNumber: '2133734253',\r\n\t\t\t\tcountry: 'US'\r\n\t\t\t},\r\n\t\t\t{ v2: true },\r\n\t\t\toldMetadata\r\n\t\t).should.equal('FIXED_LINE_OR_MOBILE')\r\n\t})\r\n\r\n\tit('should return `undefined` when the phone number is a malformed one', function() {\r\n\t\texpect(getNumberType(\r\n\t\t\t{},\r\n\t\t\t{ v2: true },\r\n\t\t\toldMetadata\r\n\t\t)).to.equal(undefined)\r\n\t})\r\n})"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,oBAA1B;AAEA,OAAOC,WAAP,MAAwB,6CAAxB,UAA+EC,IAAI,EAAE,MAArF;AAEA,OAAOC,QAAP,MAAqB,gBAArB;AAEAC,QAAQ,CAAC,eAAD,EAAkB,YAAW;EACpCC,EAAE,CAAC,gDAAD,EAAmD,YAAW;IAC/DL,aAAa,CACZ;MACCM,cAAc,EAAE,YADjB;MAECC,OAAO,EAAE;IAFV,CADY,EAKZ;MAAEC,EAAE,EAAE;IAAN,CALY,EAMZP,WANY,CAAb,CAOEQ,MAPF,CAOSC,KAPT,CAOe,sBAPf;EAQA,CATC,CAAF;EAWAL,EAAE,CAAC,oEAAD,EAAuE,YAAW;IACnFM,MAAM,CAACX,aAAa,CACnB,EADmB,EAEnB;MAAEQ,EAAE,EAAE;IAAN,CAFmB,EAGnBP,WAHmB,CAAd,CAAN,CAIGW,EAJH,CAIMF,KAJN,CAIYG,SAJZ;EAKA,CANC,CAAF;AAOA,CAnBO,CAAR"}
@@ -128,5 +128,8 @@ describe('validate', function () {
128
128
  defaultCountry: 'RU'
129
129
  }).should.equal(true);
130
130
  });
131
+ it('should validate non-geographic toll-free phone numbers', function () {
132
+ isValidNumber('+80074454123').should.equal(true);
133
+ });
131
134
  });
132
135
  //# sourceMappingURL=isValid.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"isValid.test.js","names":["metadata","type","_isValidNumber","parsePhoneNumber","isValidNumber","v2","parameters","length","push","undefined","extract","apply","describe","it","should","equal","defaultCountry","country","phone","phoneNumberTypePatterns","countries","UZ","thrower"],"sources":["../source/isValid.test.js"],"sourcesContent":["import metadata from '../metadata.min.json' assert { type: 'json' }\r\nimport _isValidNumber from './isValid.js'\r\nimport parsePhoneNumber from './parsePhoneNumber.js'\r\n\r\nfunction isValidNumber(...parameters) {\r\n\tlet v2\r\n\tif (parameters.length < 1) {\r\n\t\t// `input` parameter.\r\n\t\tparameters.push(undefined)\r\n\t} else {\r\n\t\t// Convert string `input` to a `PhoneNumber` instance.\r\n\t\tif (typeof parameters[0] === 'string') {\r\n\t\t\tv2 = true\r\n\t\t\tparameters[0] = parsePhoneNumber(parameters[0], {\r\n\t\t\t\t...parameters[1],\r\n\t\t\t\textract: false\r\n\t\t\t}, metadata)\r\n\t\t}\r\n\t}\r\n\tif (parameters.length < 2) {\r\n\t\t// `options` parameter.\r\n\t\tparameters.push(undefined)\r\n\t}\r\n\t// Set `v2` flag.\r\n\tparameters[1] = {\r\n\t\tv2,\r\n\t\t...parameters[1]\r\n\t}\r\n\t// Add `metadata` parameter.\r\n\tparameters.push(metadata)\r\n\t// Call the function.\r\n\treturn _isValidNumber.apply(this, parameters)\r\n}\r\n\r\ndescribe('validate', () => {\r\n\tit('should validate phone numbers', () => {\r\n\t\tisValidNumber('+1-213-373-4253').should.equal(true)\r\n\t\tisValidNumber('+1-213-373').should.equal(false)\r\n\r\n\t\tisValidNumber('+1-213-373-4253', undefined).should.equal(true)\r\n\r\n\t\tisValidNumber('(213) 373-4253', { defaultCountry: 'US' }).should.equal(true)\r\n\t\tisValidNumber('(213) 37', { defaultCountry: 'US' }).should.equal(false)\r\n\r\n\t\tisValidNumber({ country: 'US', phone: '2133734253' }).should.equal(true)\r\n\r\n\t\t// No \"types\" info: should return `true`.\r\n\t\tisValidNumber('+380972423740').should.equal(true)\r\n\r\n\t\tisValidNumber('0912345678', { defaultCountry: 'TW' }).should.equal(true)\r\n\r\n\t\t// Moible numbers starting 07624* are Isle of Man\r\n\t\t// which has its own \"country code\" \"IM\"\r\n\t\t// which is in the \"GB\" \"country calling code\" zone.\r\n\t\t// So while this number is for \"IM\" it's still supposed to\r\n\t\t// be valid when passed \"GB\" as a default country.\r\n\t\tisValidNumber('07624369230', { defaultCountry: 'GB' }).should.equal(true)\r\n\t})\r\n\r\n\tit('should refine phone number validation in case extended regular expressions are set for a country', () => {\r\n\t\t// Germany general validation must pass\r\n\t\tisValidNumber('961111111', { defaultCountry: 'UZ' }).should.equal(true)\r\n\r\n\t\tconst phoneNumberTypePatterns = metadata.countries.UZ[11]\r\n\r\n\t\t// Different regular expressions for precise national number validation.\r\n\t\t// `types` index in compressed array is `9` for v1.\r\n\t\t// For v2 it's 10.\r\n\t\t// For v3 it's 11.\r\n\t\tmetadata.countries.UZ[11] =\r\n\t\t[\r\n\t\t\t[\"(?:6(?:1(?:22|3[124]|4[1-4]|5[123578]|64)|2(?:22|3[0-57-9]|41)|5(?:22|3[3-7]|5[024-8])|6\\\\d{2}|7(?:[23]\\\\d|7[69])|9(?:22|4[1-8]|6[135]))|7(?:0(?:5[4-9]|6[0146]|7[12456]|9[135-8])|1[12]\\\\d|2(?:22|3[1345789]|4[123579]|5[14])|3(?:2\\\\d|3[1578]|4[1-35-7]|5[1-57]|61)|4(?:2\\\\d|3[1-579]|7[1-79])|5(?:22|5[1-9]|6[1457])|6(?:22|3[12457]|4[13-8])|9(?:22|5[1-9])))\\\\d{5}\"],\r\n\t\t\t[\"6(?:1(?:2(?:98|2[01])|35[0-4]|50\\\\d|61[23]|7(?:[01][017]|4\\\\d|55|9[5-9]))|2(?:11\\\\d|2(?:[12]1|9[01379])|5(?:[126]\\\\d|3[0-4])|7\\\\d{2})|5(?:19[01]|2(?:27|9[26])|30\\\\d|59\\\\d|7\\\\d{2})|6(?:2(?:1[5-9]|2[0367]|38|41|52|60)|3[79]\\\\d|4(?:56|83)|7(?:[07]\\\\d|1[017]|3[07]|4[047]|5[057]|67|8[0178]|9[79])|9[0-3]\\\\d)|7(?:2(?:24|3[237]|4[5-9]|7[15-8])|5(?:7[12]|8[0589])|7(?:0\\\\d|[39][07])|9(?:0\\\\d|7[079]))|9(?:2(?:1[1267]|5\\\\d|3[01]|7[0-4])|5[67]\\\\d|6(?:2[0-26]|8\\\\d)|7\\\\d{2}))\\\\d{4}|7(?:0\\\\d{3}|1(?:13[01]|6(?:0[47]|1[67]|66)|71[3-69]|98\\\\d)|2(?:2(?:2[79]|95)|3(?:2[5-9]|6[0-6])|57\\\\d|7(?:0\\\\d|1[17]|2[27]|3[37]|44|5[057]|66|88))|3(?:2(?:1[0-6]|21|3[469]|7[159])|33\\\\d|5(?:0[0-4]|5[579]|9\\\\d)|7(?:[0-3579]\\\\d|4[0467]|6[67]|8[078])|9[4-6]\\\\d)|4(?:2(?:29|5[0257]|6[0-7]|7[1-57])|5(?:1[0-4]|8\\\\d|9[5-9])|7(?:0\\\\d|1[024589]|2[0127]|3[0137]|[46][07]|5[01]|7[5-9]|9[079])|9(?:7[015-9]|[89]\\\\d))|5(?:112|2(?:0\\\\d|2[29]|[49]4)|3[1568]\\\\d|52[6-9]|7(?:0[01578]|1[017]|[23]7|4[047]|[5-7]\\\\d|8[78]|9[079]))|6(?:2(?:2[1245]|4[2-4])|39\\\\d|41[179]|5(?:[349]\\\\d|5[0-2])|7(?:0[017]|[13]\\\\d|22|44|55|67|88))|9(?:22[128]|3(?:2[0-4]|7\\\\d)|57[05629]|7(?:2[05-9]|3[37]|4\\\\d|60|7[2579]|87|9[07])))\\\\d{4}|9[0-57-9]\\\\d{7}\"]\r\n\t\t]\r\n\r\n\t\t// Extended validation must not pass for an invalid phone number\r\n\t\tisValidNumber('961111111', { defaultCountry: 'UZ' }).should.equal(false)\r\n\r\n\t\t// Extended validation must pass for a valid phone number\r\n\t\tisValidNumber('912345678', { defaultCountry: 'UZ' }).should.equal(true)\r\n\r\n\t\tmetadata.countries.UZ[11] = phoneNumberTypePatterns\r\n\t})\r\n\r\n\tit('should work in edge cases', () => {\r\n\t\t// No metadata\r\n\t\tlet thrower = () => _isValidNumber('+78005553535')\r\n\t\tthrower.should.throw('`metadata` argument not passed')\r\n\r\n\t\t// // Non-phone-number characters in a phone number\r\n\t\t// isValidNumber('+499821958a').should.equal(false)\r\n\t\t// isValidNumber('88005553535x', { defaultCountry: 'RU' }).should.equal(false)\r\n\r\n\t\t// Doesn't have `types` regexps in default metadata.\r\n\t\tisValidNumber({ country: 'UA', phone: '300000000' }).should.equal(true)\r\n\t\tisValidNumber({ country: 'UA', phone: '200000000' }).should.equal(false)\r\n\r\n\t\t// // Numerical `value`\r\n\t\t// thrower = () => isValidNumber(88005553535, { defaultCountry: 'RU' })\r\n\t\t// thrower.should.throw('A phone number must either be a string or an object of shape { phone, [country] }.')\r\n\r\n\t\t// Long country phone code\r\n\t\tisValidNumber('+3725555555').should.equal(true)\r\n\r\n\t\t// // Invalid country\r\n\t\t// thrower = () => isValidNumber({ phone: '8005553535', country: 'RUS' })\r\n\t\t// thrower.should.throw('Unknown country')\r\n\t})\r\n\r\n\tit('should accept phone number extensions', () => {\r\n\t\t// International\r\n\t\tisValidNumber('+12133734253 ext. 123').should.equal(true)\r\n\t\t// National\r\n\t\tisValidNumber('88005553535 x123', { defaultCountry: 'RU' }).should.equal(true)\r\n\t})\r\n})"],"mappings":";;;;;;AAAA,OAAOA,QAAP,MAAqB,sBAArB,UAAqDC,IAAI,EAAE,MAA3D;AACA,OAAOC,cAAP,MAA2B,cAA3B;AACA,OAAOC,gBAAP,MAA6B,uBAA7B;;AAEA,SAASC,aAAT,GAAsC;EACrC,IAAIC,EAAJ;;EADqC,kCAAZC,UAAY;IAAZA,UAAY;EAAA;;EAErC,IAAIA,UAAU,CAACC,MAAX,GAAoB,CAAxB,EAA2B;IAC1B;IACAD,UAAU,CAACE,IAAX,CAAgBC,SAAhB;EACA,CAHD,MAGO;IACN;IACA,IAAI,OAAOH,UAAU,CAAC,CAAD,CAAjB,KAAyB,QAA7B,EAAuC;MACtCD,EAAE,GAAG,IAAL;MACAC,UAAU,CAAC,CAAD,CAAV,GAAgBH,gBAAgB,CAACG,UAAU,CAAC,CAAD,CAAX,kCA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EA;;IACAV,aAAa,CAAC;MAAEa,OAAO,EAAE,IAAX;MAAiBC,KAAK,EAAE;IAAxB,CAAD,CAAb,CAAqDJ,MAArD,CAA4DC,KAA5D,CAAkE,IAAlE;IACAX,aAAa,CAAC;MAAEa,OAAO,EAAE,IAAX;MAAiBC,KAAK,EAAE;IAAxB,CAAD,CAAb,CAAqDJ,MAArD,CAA4DC,KAA5D,CAAkE,KAAlE,EAXqC,CAarC;IACA;IACA;IAEA;;IACAX,aAAa,CAAC,aAAD,CAAb,CAA6BU,MAA7B,CAAoCC,KAApC,CAA0C,IAA1C,EAlBqC,CAoBrC;IACA;IACA;EACA,CAvBC,CAAF;EAyBAF,EAAE,CAAC,uCAAD,EAA0C,YAAM;IACjD;IACAT,aAAa,CAAC,uBAAD,CAAb,CAAuCU,MAAvC,CAA8CC,KAA9C,CAAoD,IAApD,EAFiD,CAGjD;;IACAX,aAAa,CAAC,kBAAD,EAAqB;MAAEY,cAAc,EAAE;IAAlB,CAArB,CAAb,CAA4DF,MAA5D,CAAmEC,KAAnE,CAAyE,IAAzE;EACA,CALC,CAAF;AAMA,CAjFO,CAAR"}
1
+ {"version":3,"file":"isValid.test.js","names":["metadata","type","_isValidNumber","parsePhoneNumber","isValidNumber","v2","parameters","length","push","undefined","extract","apply","describe","it","should","equal","defaultCountry","country","phone","phoneNumberTypePatterns","countries","UZ","thrower"],"sources":["../source/isValid.test.js"],"sourcesContent":["import metadata from '../metadata.min.json' assert { type: 'json' }\r\nimport _isValidNumber from './isValid.js'\r\nimport parsePhoneNumber from './parsePhoneNumber.js'\r\n\r\nfunction isValidNumber(...parameters) {\r\n\tlet v2\r\n\tif (parameters.length < 1) {\r\n\t\t// `input` parameter.\r\n\t\tparameters.push(undefined)\r\n\t} else {\r\n\t\t// Convert string `input` to a `PhoneNumber` instance.\r\n\t\tif (typeof parameters[0] === 'string') {\r\n\t\t\tv2 = true\r\n\t\t\tparameters[0] = parsePhoneNumber(parameters[0], {\r\n\t\t\t\t...parameters[1],\r\n\t\t\t\textract: false\r\n\t\t\t}, metadata)\r\n\t\t}\r\n\t}\r\n\tif (parameters.length < 2) {\r\n\t\t// `options` parameter.\r\n\t\tparameters.push(undefined)\r\n\t}\r\n\t// Set `v2` flag.\r\n\tparameters[1] = {\r\n\t\tv2,\r\n\t\t...parameters[1]\r\n\t}\r\n\t// Add `metadata` parameter.\r\n\tparameters.push(metadata)\r\n\t// Call the function.\r\n\treturn _isValidNumber.apply(this, parameters)\r\n}\r\n\r\ndescribe('validate', () => {\r\n\tit('should validate phone numbers', () => {\r\n\t\tisValidNumber('+1-213-373-4253').should.equal(true)\r\n\t\tisValidNumber('+1-213-373').should.equal(false)\r\n\r\n\t\tisValidNumber('+1-213-373-4253', undefined).should.equal(true)\r\n\r\n\t\tisValidNumber('(213) 373-4253', { defaultCountry: 'US' }).should.equal(true)\r\n\t\tisValidNumber('(213) 37', { defaultCountry: 'US' }).should.equal(false)\r\n\r\n\t\tisValidNumber({ country: 'US', phone: '2133734253' }).should.equal(true)\r\n\r\n\t\t// No \"types\" info: should return `true`.\r\n\t\tisValidNumber('+380972423740').should.equal(true)\r\n\r\n\t\tisValidNumber('0912345678', { defaultCountry: 'TW' }).should.equal(true)\r\n\r\n\t\t// Moible numbers starting 07624* are Isle of Man\r\n\t\t// which has its own \"country code\" \"IM\"\r\n\t\t// which is in the \"GB\" \"country calling code\" zone.\r\n\t\t// So while this number is for \"IM\" it's still supposed to\r\n\t\t// be valid when passed \"GB\" as a default country.\r\n\t\tisValidNumber('07624369230', { defaultCountry: 'GB' }).should.equal(true)\r\n\t})\r\n\r\n\tit('should refine phone number validation in case extended regular expressions are set for a country', () => {\r\n\t\t// Germany general validation must pass\r\n\t\tisValidNumber('961111111', { defaultCountry: 'UZ' }).should.equal(true)\r\n\r\n\t\tconst phoneNumberTypePatterns = metadata.countries.UZ[11]\r\n\r\n\t\t// Different regular expressions for precise national number validation.\r\n\t\t// `types` index in compressed array is `9` for v1.\r\n\t\t// For v2 it's 10.\r\n\t\t// For v3 it's 11.\r\n\t\tmetadata.countries.UZ[11] =\r\n\t\t[\r\n\t\t\t[\"(?:6(?:1(?:22|3[124]|4[1-4]|5[123578]|64)|2(?:22|3[0-57-9]|41)|5(?:22|3[3-7]|5[024-8])|6\\\\d{2}|7(?:[23]\\\\d|7[69])|9(?:22|4[1-8]|6[135]))|7(?:0(?:5[4-9]|6[0146]|7[12456]|9[135-8])|1[12]\\\\d|2(?:22|3[1345789]|4[123579]|5[14])|3(?:2\\\\d|3[1578]|4[1-35-7]|5[1-57]|61)|4(?:2\\\\d|3[1-579]|7[1-79])|5(?:22|5[1-9]|6[1457])|6(?:22|3[12457]|4[13-8])|9(?:22|5[1-9])))\\\\d{5}\"],\r\n\t\t\t[\"6(?:1(?:2(?:98|2[01])|35[0-4]|50\\\\d|61[23]|7(?:[01][017]|4\\\\d|55|9[5-9]))|2(?:11\\\\d|2(?:[12]1|9[01379])|5(?:[126]\\\\d|3[0-4])|7\\\\d{2})|5(?:19[01]|2(?:27|9[26])|30\\\\d|59\\\\d|7\\\\d{2})|6(?:2(?:1[5-9]|2[0367]|38|41|52|60)|3[79]\\\\d|4(?:56|83)|7(?:[07]\\\\d|1[017]|3[07]|4[047]|5[057]|67|8[0178]|9[79])|9[0-3]\\\\d)|7(?:2(?:24|3[237]|4[5-9]|7[15-8])|5(?:7[12]|8[0589])|7(?:0\\\\d|[39][07])|9(?:0\\\\d|7[079]))|9(?:2(?:1[1267]|5\\\\d|3[01]|7[0-4])|5[67]\\\\d|6(?:2[0-26]|8\\\\d)|7\\\\d{2}))\\\\d{4}|7(?:0\\\\d{3}|1(?:13[01]|6(?:0[47]|1[67]|66)|71[3-69]|98\\\\d)|2(?:2(?:2[79]|95)|3(?:2[5-9]|6[0-6])|57\\\\d|7(?:0\\\\d|1[17]|2[27]|3[37]|44|5[057]|66|88))|3(?:2(?:1[0-6]|21|3[469]|7[159])|33\\\\d|5(?:0[0-4]|5[579]|9\\\\d)|7(?:[0-3579]\\\\d|4[0467]|6[67]|8[078])|9[4-6]\\\\d)|4(?:2(?:29|5[0257]|6[0-7]|7[1-57])|5(?:1[0-4]|8\\\\d|9[5-9])|7(?:0\\\\d|1[024589]|2[0127]|3[0137]|[46][07]|5[01]|7[5-9]|9[079])|9(?:7[015-9]|[89]\\\\d))|5(?:112|2(?:0\\\\d|2[29]|[49]4)|3[1568]\\\\d|52[6-9]|7(?:0[01578]|1[017]|[23]7|4[047]|[5-7]\\\\d|8[78]|9[079]))|6(?:2(?:2[1245]|4[2-4])|39\\\\d|41[179]|5(?:[349]\\\\d|5[0-2])|7(?:0[017]|[13]\\\\d|22|44|55|67|88))|9(?:22[128]|3(?:2[0-4]|7\\\\d)|57[05629]|7(?:2[05-9]|3[37]|4\\\\d|60|7[2579]|87|9[07])))\\\\d{4}|9[0-57-9]\\\\d{7}\"]\r\n\t\t]\r\n\r\n\t\t// Extended validation must not pass for an invalid phone number\r\n\t\tisValidNumber('961111111', { defaultCountry: 'UZ' }).should.equal(false)\r\n\r\n\t\t// Extended validation must pass for a valid phone number\r\n\t\tisValidNumber('912345678', { defaultCountry: 'UZ' }).should.equal(true)\r\n\r\n\t\tmetadata.countries.UZ[11] = phoneNumberTypePatterns\r\n\t})\r\n\r\n\tit('should work in edge cases', () => {\r\n\t\t// No metadata\r\n\t\tlet thrower = () => _isValidNumber('+78005553535')\r\n\t\tthrower.should.throw('`metadata` argument not passed')\r\n\r\n\t\t// // Non-phone-number characters in a phone number\r\n\t\t// isValidNumber('+499821958a').should.equal(false)\r\n\t\t// isValidNumber('88005553535x', { defaultCountry: 'RU' }).should.equal(false)\r\n\r\n\t\t// Doesn't have `types` regexps in default metadata.\r\n\t\tisValidNumber({ country: 'UA', phone: '300000000' }).should.equal(true)\r\n\t\tisValidNumber({ country: 'UA', phone: '200000000' }).should.equal(false)\r\n\r\n\t\t// // Numerical `value`\r\n\t\t// thrower = () => isValidNumber(88005553535, { defaultCountry: 'RU' })\r\n\t\t// thrower.should.throw('A phone number must either be a string or an object of shape { phone, [country] }.')\r\n\r\n\t\t// Long country phone code\r\n\t\tisValidNumber('+3725555555').should.equal(true)\r\n\r\n\t\t// // Invalid country\r\n\t\t// thrower = () => isValidNumber({ phone: '8005553535', country: 'RUS' })\r\n\t\t// thrower.should.throw('Unknown country')\r\n\t})\r\n\r\n\tit('should accept phone number extensions', () => {\r\n\t\t// International\r\n\t\tisValidNumber('+12133734253 ext. 123').should.equal(true)\r\n\t\t// National\r\n\t\tisValidNumber('88005553535 x123', { defaultCountry: 'RU' }).should.equal(true)\r\n\t})\r\n\r\n\tit('should validate non-geographic toll-free phone numbers', () => {\r\n\t\tisValidNumber('+80074454123').should.equal(true)\r\n\t})\r\n})"],"mappings":";;;;;;AAAA,OAAOA,QAAP,MAAqB,sBAArB,UAAqDC,IAAI,EAAE,MAA3D;AACA,OAAOC,cAAP,MAA2B,cAA3B;AACA,OAAOC,gBAAP,MAA6B,uBAA7B;;AAEA,SAASC,aAAT,GAAsC;EACrC,IAAIC,EAAJ;;EADqC,kCAAZC,UAAY;IAAZA,UAAY;EAAA;;EAErC,IAAIA,UAAU,CAACC,MAAX,GAAoB,CAAxB,EAA2B;IAC1B;IACAD,UAAU,CAACE,IAAX,CAAgBC,SAAhB;EACA,CAHD,MAGO;IACN;IACA,IAAI,OAAOH,UAAU,CAAC,CAAD,CAAjB,KAAyB,QAA7B,EAAuC;MACtCD,EAAE,GAAG,IAAL;MACAC,UAAU,CAAC,CAAD,CAAV,GAAgBH,gBAAgB,CAACG,UAAU,CAAC,CAAD,CAAX,kCAC5BA,UAAU,CAAC,CAAD,CADkB;QAE/BI,OAAO,EAAE;MAFsB,IAG7BV,QAH6B,CAAhC;IAIA;EACD;;EACD,IAAIM,UAAU,CAACC,MAAX,GAAoB,CAAxB,EAA2B;IAC1B;IACAD,UAAU,CAACE,IAAX,CAAgBC,SAAhB;EACA,CAlBoC,CAmBrC;;;EACAH,UAAU,CAAC,CAAD,CAAV;IACCD,EAAE,EAAFA;EADD,GA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