Skip to content

Commit

Permalink
8.1.1 (#58)
Browse files Browse the repository at this point in the history
* fix metadata

* changelog
  • Loading branch information
cedvdb authored Feb 2, 2024
1 parent 5f3d389 commit 445130d
Show file tree
Hide file tree
Showing 12 changed files with 254 additions and 204 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 8.1.1
- updated metadata

## 8.1.0
- updated metadata
- fix for local phone numbers not parsing accurately (issue 46)
Expand Down
20 changes: 17 additions & 3 deletions lib/src/metadata/generated/metadata_formats_by_iso_code.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2591,7 +2591,7 @@ const metadataFormatsByIsoCode = <IsoCode, PhoneMetadataFormats>{
PhoneMetadataFormat(
pattern: r"(\d{3})(\d{3})(\d{3,4})",
nationalPrefixFormattingRule: null,
leadingDigits: ["1(?:44|[679])|[378]"],
leadingDigits: ["1(?:44|[679])|[378]|43"],
format: r"$1 $2 $3",
intlFormat: null,
),
Expand Down Expand Up @@ -3057,7 +3057,7 @@ const metadataFormatsByIsoCode = <IsoCode, PhoneMetadataFormats>{
PhoneMetadataFormat(
pattern: r"(\d)(\d{3})(\d{3})",
nationalPrefixFormattingRule: r"$NP$FG",
leadingDigits: ["[4-6]"],
leadingDigits: ["4[67]|[56]"],
format: r"$1 $2 $3",
intlFormat: null,
),
Expand All @@ -3071,7 +3071,7 @@ const metadataFormatsByIsoCode = <IsoCode, PhoneMetadataFormats>{
PhoneMetadataFormat(
pattern: r"(\d{2})(\d{3})(\d{4})",
nationalPrefixFormattingRule: r"$NP$FG",
leadingDigits: ["[23578]"],
leadingDigits: ["[2-578]"],
format: r"$1 $2 $3",
intlFormat: null,
)
Expand Down Expand Up @@ -3786,6 +3786,20 @@ const metadataFormatsByIsoCode = <IsoCode, PhoneMetadataFormats>{
format: r"$1 $2 $3",
intlFormat: null,
),
PhoneMetadataFormat(
pattern: r"(\d{3})(\d{3})(\d{4})",
nationalPrefixFormattingRule: r"$NP$FG",
leadingDigits: ["20[129]"],
format: r"$1 $2 $3",
intlFormat: null,
),
PhoneMetadataFormat(
pattern: r"(\d{4})(\d{2})(\d{4})",
nationalPrefixFormattingRule: r"$NP$FG",
leadingDigits: ["2"],
format: r"$1 $2 $3",
intlFormat: null,
),
PhoneMetadataFormat(
pattern: r"(\d{3})(\d{4})(\d{4,5})",
nationalPrefixFormattingRule: r"$NP$FG",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ const metadataLenghtsByIsoCode = {
IsoCode.NG: PhoneMetadataLengths(
general: [],
mobile: [10],
fixedLine: [7, 8],
fixedLine: [7, 8, 10],
),
IsoCode.NI: PhoneMetadataLengths(
general: [],
Expand Down
61 changes: 31 additions & 30 deletions lib/src/metadata/generated/metadata_patterns_by_iso_code.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ const metadataPatternsByIsoCode = {
general:
r"1(?:[0-79]\d{7}(?:\d(?:\d{2})?)?|8[0-24-9]\d{7})|[2-478]\d{8}|1\d{4,7}",
mobile:
r"4(?:(?:79|94)[01]|83[0-389])\d{5}|4(?:[0-3]\d|4[047-9]|5[0-25-9]|6[0-26-9]|7[02-8]|8[0-24-9]|9[0-37-9])\d{6}",
r"4(?:(?:79|94)[01]|83[0-389])\d{5}|4(?:[0-3]\d|4[047-9]|5[0-25-9]|6[0-36-9]|7[02-8]|8[0-24-9]|9[0-37-9])\d{6}",
fixedLine:
r"(?:(?:2(?:[0-26-9]\d|3[0-8]|4[02-9]|5[0135-9])|3(?:[0-3589]\d|4[0-578]|6[1-9]|7[0-35-9])|7(?:[013-57-9]\d|2[0-8]))\d{3}|8(?:51(?:0(?:0[03-9]|[12479]\d|3[2-9]|5[0-8]|6[1-9]|8[0-7])|1(?:[0235689]\d|1[0-69]|4[0-589]|7[0-47-9])|2(?:0[0-79]|[18][13579]|2[14-9]|3[0-46-9]|[4-6]\d|7[89]|9[0-4]))|(?:6[0-8]|[78]\d)\d{3}|9(?:[02-9]\d{3}|1(?:(?:[0-58]\d|6[0135-9])\d|7(?:0[0-24-9]|[1-9]\d)|9(?:[0-46-9]\d|5[0-79])))))\d{3}",
r"(?:(?:(?:2(?:[0-26-9]\d|3[0-8]|4[02-9]|5[0135-9])|7(?:[013-57-9]\d|2[0-8]))\d|3(?:(?:[0-3589]\d|6[1-9]|7[0-35-9])\d|4(?:[0-578]\d|90)))\d\d|8(?:51(?:0(?:0[03-9]|[12479]\d|3[2-9]|5[0-8]|6[1-9]|8[0-7])|1(?:[0235689]\d|1[0-69]|4[0-589]|7[0-47-9])|2(?:0[0-79]|[18][13579]|2[14-9]|3[0-46-9]|[4-6]\d|7[89]|9[0-4])|3\d\d)|(?:6[0-8]|[78]\d)\d{3}|9(?:[02-9]\d{3}|1(?:(?:[0-58]\d|6[0135-9])\d|7(?:0[0-24-9]|[1-9]\d)|9(?:[0-46-9]\d|5[0-79])))))\d{3}",
),
IsoCode.AW: PhoneMetadataPatterns(
nationalPrefixForParsing: null,
Expand Down Expand Up @@ -197,7 +197,7 @@ const metadataPatternsByIsoCode = {
nationalPrefixForParsing: null,
nationalPrefixTransformRule: null,
general: r"[24-689]\d{7}",
mobile: r"(?:4[0-6]|[56]\d|9[013-9])\d{6}",
mobile: r"(?:4[0-7]|[56]\d|9[013-9])\d{6}",
fixedLine: r"2(?:02|1[037]|2[45]|3[68]|4\d)\d{5}",
),
IsoCode.BL: PhoneMetadataPatterns(
Expand All @@ -211,7 +211,7 @@ const metadataPatternsByIsoCode = {
nationalPrefixForParsing: r"([2-9]\d{6})$|1",
nationalPrefixTransformRule: r"441$1",
general: r"(?:441|[58]\d\d|900)\d{7}",
mobile: r"441(?:[2378]\d|5[0-39]|92)\d{5}",
mobile: r"441909\d{4}|441(?:[2378]\d|5[0-39]|92)\d{5}",
fixedLine: r"441(?:[46]\d\d|5(?:4\d|60|89))\d{4}",
),
IsoCode.BN: PhoneMetadataPatterns(
Expand Down Expand Up @@ -303,7 +303,7 @@ const metadataPatternsByIsoCode = {
nationalPrefixTransformRule: r"8$1",
general: r"1(?:[0-79]\d{8}(?:\d{2})?|8[0-24-9]\d{7})|[148]\d{8}|1\d{5,7}",
mobile:
r"4(?:(?:79|94)[01]|83[0-389])\d{5}|4(?:[0-3]\d|4[047-9]|5[0-25-9]|6[0-26-9]|7[02-8]|8[0-24-9]|9[0-37-9])\d{6}",
r"4(?:(?:79|94)[01]|83[0-389])\d{5}|4(?:[0-3]\d|4[047-9]|5[0-25-9]|6[0-36-9]|7[02-8]|8[0-24-9]|9[0-37-9])\d{6}",
fixedLine:
r"8(?:51(?:0(?:02|31|60|89)|1(?:18|76)|223)|91(?:0(?:1[0-2]|29)|1(?:[28]2|50|79)|2(?:10|64)|3(?:[06]8|22)|4[29]8|62\d|70[23]|959))\d{3}",
),
Expand Down Expand Up @@ -421,7 +421,7 @@ const metadataPatternsByIsoCode = {
nationalPrefixTransformRule: r"8$1",
general: r"1(?:[0-79]\d{8}(?:\d{2})?|8[0-24-9]\d{7})|[148]\d{8}|1\d{5,7}",
mobile:
r"4(?:(?:79|94)[01]|83[0-389])\d{5}|4(?:[0-3]\d|4[047-9]|5[0-25-9]|6[0-26-9]|7[02-8]|8[0-24-9]|9[0-37-9])\d{6}",
r"4(?:(?:79|94)[01]|83[0-389])\d{5}|4(?:[0-3]\d|4[047-9]|5[0-25-9]|6[0-36-9]|7[02-8]|8[0-24-9]|9[0-37-9])\d{6}",
fixedLine:
r"8(?:51(?:0(?:01|30|59|88)|1(?:17|46|75)|2(?:22|35))|91(?:00[6-9]|1(?:[28]1|49|78)|2(?:09|63)|3(?:12|26|75)|4(?:56|97)|64\d|7(?:0[01]|1[0-2])|958))\d{3}",
),
Expand All @@ -436,7 +436,7 @@ const metadataPatternsByIsoCode = {
nationalPrefixForParsing: null,
nationalPrefixTransformRule: null,
general: r"(?:[2-578]\d|60)\d{7}|9\d{8,11}",
mobile: r"(?:60[1-8]|7(?:0[2-5]|[2379]\d))\d{6}",
mobile: r"7060\d{5}|(?:60[1-8]|7(?:0[2-5]|[2379]\d))\d{6}",
fixedLine: r"(?:2\d|3[1257-9]|4[16-9]|5[13-9])\d{7}",
),
IsoCode.DE: PhoneMetadataPatterns(
Expand Down Expand Up @@ -582,7 +582,8 @@ const metadataPatternsByIsoCode = {
nationalPrefixTransformRule: null,
general: r"[1-9]\d{8}",
mobile: r"(?:6(?:[0-24-8]\d|3[0-8]|9[589])|7[3-9]\d)\d{6}",
fixedLine: r"59[1-9]\d{6}|(?:[1-3]\d|4[1-9]|5[0-8])\d{7}",
fixedLine:
r"(?:26[013-9]|59[1-35-9])\d{6}|(?:[13]\d|2[0-57-9]|4[1-9]|5[0-8])\d{7}",
),
IsoCode.GA: PhoneMetadataPatterns(
nationalPrefixForParsing:
Expand Down Expand Up @@ -623,7 +624,7 @@ const metadataPatternsByIsoCode = {
nationalPrefixTransformRule: null,
general: r"[56]94\d{6}|(?:80|9\d)\d{7}",
mobile: r"694(?:[0-249]\d|3[0-8])\d{4}",
fixedLine: r"594(?:[02-49]\d|1[0-4]|5[6-9]|6[0-3]|80)\d{4}",
fixedLine: r"594(?:[02-49]\d|1[0-5]|5[6-9]|6[0-3]|80)\d{4}",
),
IsoCode.GG: PhoneMetadataPatterns(
nationalPrefixForParsing: r"([25-9]\d{5})$|0",
Expand Down Expand Up @@ -720,7 +721,7 @@ const metadataPatternsByIsoCode = {
nationalPrefixForParsing: null,
nationalPrefixTransformRule: null,
general: r"(?:[2-8]\d{3}|9008)\d{3}",
mobile: r"(?:510|6\d\d|7(?:0\d|1[0-8]|25|49))\d{4}",
mobile: r"(?:510|6\d\d|7(?:[01]\d|2[156]|49))\d{4}",
fixedLine:
r"(?:2(?:1[6-9]|2[0-35-9]|3[1-4]|5[3-9]|6\d|7[0-79])|3(?:2[25-9]|3\d)|4(?:4[0-24]|5[56])|50[0-6]|77[1-57])\d{4}",
),
Expand All @@ -729,7 +730,7 @@ const metadataPatternsByIsoCode = {
nationalPrefixTransformRule: null,
general: r"8[0-46-9]\d{6,7}|9\d{4,7}|(?:[2-7]|9\d{3})\d{7}",
mobile:
r"(?:4(?:44[5-9]|6(?:1[0-7]|4[0-57-9]|6[0-4]))|5(?:73[0-6]|95[0-8])|6(?:26[013-8]|66[0-3])|70(?:7[1-6]|8[0-4])|848[0-25-9]|9(?:29[013-9]|59[0-4]|899))\d{4}|(?:4(?:4[0156]|6[02357-9])|5(?:[1-59][0-46-9]|6[0-4689]|7[0-246-9])|6(?:0[1-9]|[13-59]\d|[268][0-57-9]|7[0-79])|709|84[09]|9(?:0[1-9]|1[02-9]|[2358][0-8]|[467]\d))\d{5}",
r"(?:4(?:44[05-9]|6(?:1[0-7]|4[0-57-9]|6[0-4]))|5(?:73[0-6]|95[0-8])|6(?:26[013-8]|66[0-3])|70(?:7[1-6]|8[0-4])|848[0-35-9]|9(?:29[013-9]|39[01]|59[0-4]|899))\d{4}|(?:4(?:4[015-8]|6[02357-9])|5(?:[1-59][0-46-9]|6[0-4689]|7[0-246-9])|6(?:0[1-9]|[13-59]\d|[268][0-57-9]|7[0-79])|70[129]|84[09]|9(?:0[1-9]|1[02-9]|[2358][0-8]|[467]\d))\d{5}",
fixedLine:
r"(?:2(?:[13-9]\d|2[013-9])\d|3(?:(?:[1569][0-24-9]|4[0-246-9]|7[0-24-69])\d|8(?:4[0-8]|[59]\d|6[01]))|58(?:0[1-9]|1[2-9]))\d{4}",
),
Expand All @@ -746,7 +747,7 @@ const metadataPatternsByIsoCode = {
nationalPrefixTransformRule: null,
general: r"(?:[24-69]\d|3[0-79])\d{7}|80\d{5,7}|[1-79]\d{7}|6\d{5,6}",
mobile:
r"9(?:(?:0[1-9]|[12589]\d)\d\d|7(?:[0679]\d\d|5(?:[01]\d|44|77|9[5-7])))\d{4}|98\d{6}",
r"9(?:(?:0[1-9]|[12589]\d)\d\d|7(?:[0679]\d\d|5(?:[01]\d|44|55|77|9[5-7])))\d{4}|98\d{6}",
fixedLine: r"1\d{7}|(?:2[0-3]|3[1-5]|4[02-47-9]|5[1-3])\d{6,7}",
),
IsoCode.HT: PhoneMetadataPatterns(
Expand Down Expand Up @@ -826,7 +827,7 @@ const metadataPatternsByIsoCode = {
mobile:
r"9(?:(?:0(?:[0-35]\d|4[4-6])|(?:[13]\d|2[0-3])\d)\d|9(?:[0-46]\d\d|5[15]0|8(?:[12]\d|88)|9(?:0[0-3]|[19]\d|21|69|77|8[7-9])))\d{5}",
fixedLine:
r"(?:1[137]|2[13-68]|3[1458]|4[145]|5[1468]|6[16]|7[1467]|8[13467])(?:[03-57]\d{7}|[16]\d{3}(?:\d{4})?|[289]\d{3}(?:\d(?:\d{3})?)?)|94(?:000[09]|2(?:121|[2689]0\d)|30[0-2]\d|4(?:111|40\d))\d{4}",
r"(?:1[137]|2[13-68]|3[1458]|4[145]|5[1468]|6[16]|7[1467]|8[13467])(?:[03-57]\d{7}|[16]\d{3}(?:\d{4})?|[289]\d{3}(?:\d(?:\d{3})?)?)|94(?:000[09]|(?:12\d|30[0-2])\d|2(?:121|[2689]0\d)|4(?:111|40\d))\d{4}",
),
IsoCode.IS: PhoneMetadataPatterns(
nationalPrefixForParsing: null,
Expand All @@ -841,8 +842,8 @@ const metadataPatternsByIsoCode = {
nationalPrefixForParsing: null,
nationalPrefixTransformRule: null,
general:
r"0\d{5,10}|1\d{8,10}|3(?:[0-8]\d{7,10}|9\d{7,8})|(?:55|70)\d{8}|8\d{5}(?:\d{2,4})?",
mobile: r"3[1-9]\d{8}|3[2-9]\d{7}",
r"0\d{5,10}|1\d{8,10}|3(?:[0-8]\d{7,10}|9\d{7,8})|(?:43|55|70)\d{8}|8\d{5}(?:\d{2,4})?",
mobile: r"3[2-9]\d{7,8}|(?:31|43)\d{8}",
fixedLine:
r"0669[0-79]\d{1,6}|0(?:1(?:[0159]\d|[27][1-5]|31|4[1-4]|6[1356]|8[2-57])|2\d\d|3(?:[0159]\d|2[1-4]|3[12]|[48][1-6]|6[2-59]|7[1-7])|4(?:[0159]\d|[23][1-9]|4[245]|6[1-5]|7[1-4]|81)|5(?:[0159]\d|2[1-5]|3[2-6]|4[1-79]|6[4-6]|7[1-578]|8[3-8])|6(?:[0-57-9]\d|6[0-8])|7(?:[0159]\d|2[12]|3[1-7]|4[2-46]|6[13569]|7[13-6]|8[1-59])|8(?:[0159]\d|2[3-578]|3[1-356]|[6-8][1-5])|9(?:[0159]\d|[238][1-5]|4[12]|6[1-8]|7[1-6]))\d{2,7}",
),
Expand Down Expand Up @@ -1014,8 +1015,9 @@ const metadataPatternsByIsoCode = {
IsoCode.LR: PhoneMetadataPatterns(
nationalPrefixForParsing: null,
nationalPrefixTransformRule: null,
general: r"(?:[25]\d|33|77|88)\d{7}|(?:2\d|[4-6])\d{6}",
mobile: r"(?:(?:(?:22|33)0|555|(?:77|88)\d)\d|4[67])\d{5}|[56]\d{6}",
general: r"(?:[245]\d|33|77|88)\d{7}|(?:2\d|[4-6])\d{6}",
mobile:
r"(?:(?:(?:22|33)0|555|(?:77|88)\d)\d|4(?:240|[67]))\d{5}|[56]\d{6}",
fixedLine: r"2\d{7}",
),
IsoCode.LS: PhoneMetadataPatterns(
Expand Down Expand Up @@ -1108,8 +1110,8 @@ const metadataPatternsByIsoCode = {
nationalPrefixForParsing: null,
nationalPrefixTransformRule: null,
general: r"329\d{4}|(?:[256]\d|45)\d{5}",
mobile: r"(?:(?:23|54)5|329|45[356])\d{4}",
fixedLine: r"(?:247|45[78]|528|625)\d{4}",
mobile: r"(?:(?:23|54)5|329|45[35-8])\d{4}",
fixedLine: r"(?:247|528|625)\d{4}",
),
IsoCode.MK: PhoneMetadataPatterns(
nationalPrefixForParsing: null,
Expand Down Expand Up @@ -1167,7 +1169,7 @@ const metadataPatternsByIsoCode = {
nationalPrefixTransformRule: null,
general: r"596\d{6}|(?:69|80|9\d)\d{7}",
mobile: r"69(?:6(?:[0-46-9]\d|5[0-6])|727)\d{4}",
fixedLine: r"596(?:[03-7]\d|10|2[7-9]|8[0-39]|9[04-9])\d{4}",
fixedLine: r"596(?:[03-7]\d|1[05]|2[7-9]|8[0-39]|9[04-9])\d{4}",
),
IsoCode.MR: PhoneMetadataPatterns(
nationalPrefixForParsing: null,
Expand Down Expand Up @@ -1274,11 +1276,11 @@ const metadataPatternsByIsoCode = {
IsoCode.NG: PhoneMetadataPatterns(
nationalPrefixForParsing: null,
nationalPrefixTransformRule: null,
general: r"(?:[124-7]|9\d{3})\d{6}|[1-9]\d{7}|[78]\d{9,13}",
general: r"2[0-24-9]\d{8}|[78]\d{10,13}|[7-9]\d{9}|[1-9]\d{7}|[124-7]\d{6}",
mobile:
r"(?:702[0-24-9]|819[01])\d{6}|(?:70[13-689]|8(?:0[1-9]|1[0-8])|9(?:0[1-9]|1[1-356]))\d{7}",
r"(?:702[0-24-9]|819[01])\d{6}|(?:7(?:0[13-689]|[12]\d)|8(?:0[1-9]|1[0-8])|9(?:0[1-9]|1[1-6]))\d{7}",
fixedLine:
r"(?:(?:[1-356]\d|4[02-8]|8[2-9])\d|9(?:0[3-9]|[1-9]\d))\d{5}|7(?:0(?:[013-689]\d|2[0-24-9])\d{3,4}|[1-79]\d{6})|(?:[12]\d|4[147]|5[14579]|6[1578]|7[1-3578])\d{5}",
r"20(?:[1259]\d|3[013-9]|4[1-8]|6[024-689]|7[1-79]|8[2-9])\d{6}|(?:(?:[1-356]\d|4[02-8]|8[2-9])\d|9(?:0[3-9]|[1-9]\d))\d{5}|7(?:0(?:[013-689]\d|2[0-24-9])\d{3,4}|[1-79]\d{6})|(?:[12]\d|4[147]|5[14579]|6[1578]|7[1-3578])\d{5}",
),
IsoCode.NI: PhoneMetadataPatterns(
nationalPrefixForParsing: null,
Expand Down Expand Up @@ -1369,7 +1371,7 @@ const metadataPatternsByIsoCode = {
nationalPrefixForParsing: null,
nationalPrefixTransformRule: null,
general: r"(?:180|[78]\d{3})\d{4}|(?:[2-589]\d|64)\d{5}",
mobile: r"(?:7\d|8[128])\d{6}",
mobile: r"(?:7\d|8[1-38])\d{6}",
fixedLine: r"(?:(?:3[0-2]|4[257]|5[34]|9[78])\d|64[1-9]|85[02-46-9])\d{4}",
),
IsoCode.PH: PhoneMetadataPatterns(
Expand Down Expand Up @@ -1534,8 +1536,7 @@ const metadataPatternsByIsoCode = {
nationalPrefixForParsing: null,
nationalPrefixTransformRule: null,
general: r"(?:(?:1\d|8)\d\d|7000)\d{7}|[3689]\d{7}",
mobile:
r"8(?:08[013-9]|95[0-2])\d{4}|(?:8(?:0[1-7]|[1-8]\d|9[0-4])|9[0-8]\d)\d{5}",
mobile: r"895[0-2]\d{4}|(?:8(?:0[1-8]|[1-8]\d|9[0-4])|9[0-8]\d)\d{5}",
fixedLine: r"662[0-24-9]\d{4}|6(?:[0-578]\d|6[013-57-9]|9[0-35-9])\d{5}",
),
IsoCode.SH: PhoneMetadataPatterns(
Expand Down Expand Up @@ -1681,7 +1682,7 @@ const metadataPatternsByIsoCode = {
nationalPrefixForParsing: null,
nationalPrefixTransformRule: null,
general: r"(?:001800|[2-57]|[689]\d)\d{7}|1\d{7,9}",
mobile: r"671[0-8]\d{5}|(?:14|6[1-6]|[89]\d)\d{7}",
mobile: r"67(?:1[0-8]|2[4-7])\d{5}|(?:14|6[1-6]|[89]\d)\d{7}",
fixedLine: r"(?:1[0689]|2\d|3[2-9]|4[2-5]|5[2-6]|7[3-7])\d{6}",
),
IsoCode.TJ: PhoneMetadataPatterns(
Expand Down Expand Up @@ -1790,9 +1791,9 @@ const metadataPatternsByIsoCode = {
nationalPrefixTransformRule: null,
general: r"[2-9]\d{9}|3\d{6}",
mobile:
r"(?:5056(?:[0-35-9]\d|4[468])|73020\d)\d{4}|(?:472[24]|505[2-57-9]|983[289])\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-57-9]|3[149]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-57-9]|1[02-9]|2[013569]|3[0-24679]|4[167]|5[0-2]|6[0149]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-47-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|[34][016]|5[01679]|6[0-279]|78|8[0-29])|7(?:0[1-46-8]|1[2-9]|2[04-7]|3[1247]|4[037]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[068]|3[0-2589]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-389]|8[04-69]))[2-9]\d{6}",
r"(?:5056(?:[0-35-9]\d|4[468])|7302[01]\d)\d{4}|(?:472[24]|505[2-57-9]|983[289])\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-57-9]|3[149]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-57-9]|1[02-9]|2[013569]|3[0-24679]|4[167]|5[0-2]|6[0149]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-47-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|3[016]|4[0156]|5[01679]|6[0-279]|78|8[0-29])|7(?:0[1-46-8]|1[2-9]|2[04-7]|3[1247]|4[037]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[068]|3[0-2589]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-389]|8[04-69]))[2-9]\d{6}",
fixedLine:
r"(?:5056(?:[0-35-9]\d|4[468])|73020\d)\d{4}|(?:472[24]|505[2-57-9]|983[289])\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-57-9]|3[149]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-57-9]|1[02-9]|2[013569]|3[0-24679]|4[167]|5[0-2]|6[0149]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-47-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|[34][016]|5[01679]|6[0-279]|78|8[0-29])|7(?:0[1-46-8]|1[2-9]|2[04-7]|3[1247]|4[037]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[068]|3[0-2589]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-389]|8[04-69]))[2-9]\d{6}",
r"(?:5056(?:[0-35-9]\d|4[468])|7302[01]\d)\d{4}|(?:472[24]|505[2-57-9]|983[289])\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-57-9]|3[149]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-57-9]|1[02-9]|2[013569]|3[0-24679]|4[167]|5[0-2]|6[0149]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-47-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|3[016]|4[0156]|5[01679]|6[0-279]|78|8[0-29])|7(?:0[1-46-8]|1[2-9]|2[04-7]|3[1247]|4[037]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[068]|3[0-2589]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-389]|8[04-69]))[2-9]\d{6}",
),
IsoCode.UY: PhoneMetadataPatterns(
nationalPrefixForParsing: null,
Expand Down Expand Up @@ -1900,7 +1901,7 @@ const metadataPatternsByIsoCode = {
nationalPrefixTransformRule: null,
general: r"(?:80|9\d)\d{7}|(?:26|63)9\d{6}",
mobile: r"639(?:0[0-79]|1[019]|[267]\d|3[09]|40|5[05-9]|9[04-79])\d{4}",
fixedLine: r"269(?:0[0-467]|5[0-4]|6\d|[78]0)\d{4}",
fixedLine: r"269(?:0[0-467]|15|5[0-4]|6\d|[78]0)\d{4}",
),
IsoCode.ZA: PhoneMetadataPatterns(
nationalPrefixForParsing: null,
Expand Down
8 changes: 5 additions & 3 deletions lib/src/parsers/_country_code_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ abstract class CountryCodeParser {
phoneNumber.length,
Constants.maxLengthCountryCallingCode,
);
var potentialCountryCode = phoneNumber.substring(0, maxCountryCodeLength);
var longestPotentialCountryCode =
phoneNumber.substring(0, maxCountryCodeLength);

for (var i = 1; i <= potentialCountryCode.length; i++) {
final potentialCountryCodeFit = potentialCountryCode.substring(0, i);
for (var i = 1; i <= longestPotentialCountryCode.length; i++) {
final potentialCountryCodeFit =
longestPotentialCountryCode.substring(0, i);
final nsn = phoneNumber.substring(i);
final countryMetadata = MetadataFinder.findMetadataForCountryCode(
potentialCountryCodeFit,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/parsers/phone_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ abstract class PhoneParser {
// if the phone number is valid as is and use that, other wise if it is valid
// without the country code we remove the country code.
final countryCode = destinationMetadata.countryCode;
if (exitCode.isNotEmpty) {
if (exitCode.isNotEmpty && national.length >= countryCode.length) {
national = national.substring(countryCode.length);
} else if (national.startsWith(countryCode)) {
final withoutCountryCode = national.substring(countryCode.length);
Expand Down
Loading

0 comments on commit 445130d

Please sign in to comment.