Commit 8cd92267 authored by gregor herrmann's avatar gregor herrmann

New upstream version 3.4004

parents b7716917 4413e46b
2018-01-08 3.4003 UK "protected" numbers should have false is_allocated();
2018-04-10 3.4004 We now have some data from libphonenumber for Kosovo
(see https://github.com/DrHyde/perl-modules-Number-Phone/issues/66);
Kosovo has migrated to +383 so get rid of the special cases in +377 etc;
Bug-fix for when national prefix transforms apply
(see https://github.com/DrHyde/perl-modules-Number-Phone/pull/87);
N::P::Country::Data is now mostly built from libphonenumber
(see https://github.com/DrHyde/perl-modules-Number-Phone/issues/34);
Corrected the Vatican's area code within the Italian numbering plan;
Added a special case for San Marino within the Italian numbering plan;
Data updates
2018-02-03 3.4003 UK "protected" numbers should have false is_allocated();
Bugfix for countries that don't have area names (see
https://github.com/DrHyde/perl-modules-Number-Phone/issues/64);
Match libphonenumber's behaviour when countries have identical
......
......@@ -324,6 +324,7 @@ lib/Number/Phone/StubCountry/VN.pm
lib/Number/Phone/StubCountry/VU.pm
lib/Number/Phone/StubCountry/WF.pm
lib/Number/Phone/StubCountry/WS.pm
lib/Number/Phone/StubCountry/XK.pm
lib/Number/Phone/StubCountry/YE.pm
lib/Number/Phone/StubCountry/YT.pm
lib/Number/Phone/StubCountry/ZA.pm
......
......@@ -60,5 +60,5 @@
"url" : "https://github.com/DrHyde/perl-modules-Number-Phone"
}
},
"version" : "3.4003"
"version" : "3.4004"
}
......@@ -36,4 +36,4 @@ requires:
resources:
bugtracker: https://github.com/DrHyde/perl-modules-Number-Phone/issues
repository: https://github.com/DrHyde/perl-modules-Number-Phone
version: '3.4003'
version: '3.4004'
......@@ -8,7 +8,7 @@ use Number::Phone::Country qw(noexport);
use Number::Phone::StubCountry;
# MUST be in format N.NNNN, see https://github.com/DrHyde/perl-modules-Number-Phone/issues/58
our $VERSION = '3.4003';
our $VERSION = '3.4004';
my $NOSTUBS = 0;
sub import {
......@@ -148,6 +148,17 @@ warnings. All code to support those calling conventions has now been removed.
Until 2017 we ued KOS for the country code for Kosovo, that has now changed to
XK. See L<Number::Phone::Country>.
From version 3.4000 to 3.4003 inclusive we accepted any old garbage after
+383 as being valid, as the Kosovo numbering plan had not been published.
Now that that has been published, we use libphonenumber data, and validate
against it.
The prefix codes in 3.4003 and earlier were managed by hand and so got out
of date. After that release they are mostly derived from libphonenumber.
libphonenumber's data includes carrier selection codes when they are
mandatory for dialling so those are now included. This sometimes means that
some random carrier has been arbitrarily priveleged over others.
=head1 COMPATIBILTY WITH libphonenumber
libphonenumber is a similar project for other languages, maintained
......@@ -169,16 +180,6 @@ of Number::Phone that will use the libphonenumber-derived stub classes even
when extra data is available in, for example, Number::Phone::UK. You might
want to do this for compatibility or performance. Number::Phone::UK is quite slow, because it uses a huge database for some of its features.
=head1 SPECIAL CASE FOR KOSOVO
Kosovo has been allocated country code +383, and it is apparently in use as of
March 2017, but no number plan has been published and libphonenumber has no
data. Therefore *all* +383 numbers will be considered valid. This is strictly
speaking the wrong thing to do, but the alternative is to consider them all
invalid, which is just as wrong. This will no doubt change in the future.
See L<https://github.com/DrHyde/perl-modules-Number-Phone/issues/66> and
L<https://github.com/googlei18n/libphonenumber/issues/1486>.
=cut
sub _new_args {
......@@ -235,8 +236,7 @@ sub _make_stub_object {
return bless({
country_code => $country_idd,
country => $country_name,
# Kosovo special case
is_valid => ($country_idd eq '383') ? 1 : undef,
is_valid => undef,
number => $local_number,
}, 'Number::Phone::StubCountry');
}
......
......@@ -5,7 +5,7 @@ use Number::Phone::Country::Data;
# *_codes are global so we can mock in some tests
use vars qw($VERSION %idd_codes %prefix_codes);
$VERSION = 1.93;
$VERSION = 1.94;
my $use_uk = 0;
sub import {
......@@ -31,7 +31,9 @@ sub phone2country {
our %NANP_areas = (
CA => do {
# from http://www.cnac.ca/co_codes/co_code_status.htm, 2017-07-14
# see http://www.cnac.ca/co_codes/co_code_status.htm
# checked on 2018-03-25
# next check due 2018-09-25 (semi-annually)
my $canada = join('|', qw(
204 226 236 249 250 289
306 343 365 367
......@@ -43,41 +45,50 @@ our %NANP_areas = (
902 905
));
# handful of non-geographic country-specific codes ...
# see https://en.wikipedia.org/wiki/Area_code_600
# checked on 2018-03-25
# next check due 2018-09-25 (semi-annually)
$canada = join('|', $canada, 600, 622, 633, 644, 655, 677, 688);
},
US => do {
# from http://www.nanpa.com/enas/geoAreaCodeAlphabetReport.do, 2017-07-14
# see https://www.allareacodes.com/area_code_listings_by_state.htm
# checked on 2018-03-25
# next check due 2018-09-25 (semi-annually)
my $usa = join('|', qw(
907 334 251 205 938 256 501 479 870 520 480 928 602 623 619 562 628 650 657 661 408 415 424 442 626 559 530 510 323 310 951 949 925 916 209 213 669 707 714 747 760 805 818 831 858 909 719 303 970 720 475 203 860 959 202 302 407 561 727 754 772 786 813 850 863 904 941 954 305 321 352 386 239 404 229 762 470 678 706 478 770 912 808 515 712 641 319 563 208 708 224 217 618 630 331 312 309 872 847 815 779 773 219 317 463 812 574 930 765 260 913 316 785 620 502 859 364 270 606 225 985 504 337 318 774 617 351 508 857 978 413 339 781 240 410 301 443 667 207 734 248 231 586 616 517 313 269 989 947 906 810 952 320 218 651 763 612 507 314 573 660 816 636 417 601 662 228 769 406 704 252 980 828 910 919 743 984 336 701 308 531 402 603 856 848 908 732 973 201 609 862 551 575 505 725 702 775 315 332 680 347 212 585 646 516 518 631 607 845 934 716 718 929 917 914 614 567 513 380 330 937 740 234 220 216 440 419 405 539 580 918 541 971 503 458 610 412 215 717 724 814 484 570 878 267 272 401 843 803 864 854 605 931 423 629 901 615 865 731 737 806 817 512 832 903 915 940 956 972 979 936 281 325 346 361 713 682 254 214 210 469 432 430 409 830 385 435 801 434 703 757 571 804 276 540 802 360 253 206 425 509 262 920 534 414 608 715 304 681 307
205 251 256 334 938 907 480 520 602 623 928 479 501 870 209 213 310 323 408 415 424 442 510 530 559 562 619 626 628 650 657 661 669 707 714 747 760 805 818 831 858 909 916 925 949 951 303 719 720 970 203 475 860 959 302 239 305 321 352 386 407 561 727 754 772 786 813 850 863 904 941 954 229 404 470 478 678 706 762 770 912 808 208 217 224 309 312 331 618 630 708 773 779 815 847 872 219 260 317 463 574 765 812 930 319 515 563 641 712 316 620 785 913 270 364 502 606 859 225 318 337 504 985 207 240 301 410 443 667 339 351 413 508 617 774 781 857 978 231 248 269 313 517 586 616 734 810 906 947 989 218 320 507 612 651 763 952 228 601 662 769 314 417 573 636 660 816 406 308 402 531 702 725 775 603 201 551 609 732 848 856 862 908 973 505 575 212 315 332 347 516 518 585 607 631 646 680 716 718 845 914 917 929 934 252 336 704 743 828 910 919 980 984 701 216 220 234 330 380 419 440 513 567 614 740 937 405 539 580 918 458 503 541 971 215 267 272 412 484 570 610 717 724 814 878 401 803 843 854 864 605 423 615 629 731 865 901 931 210 214 254 281 325 346 361 409 430 432 469 512 682 713 737 806 817 830 832 903 915 936 940 956 972 979 385 435 801 802 276 434 540 571 703 757 804 206 253 360 425 509 202 304 681 262 414 534 608 715 920 307
));
# handful of non-geographic country-specific codes ...
$usa = join('|', $usa, 710);
# see https://en.wikipedia.org/wiki/Area_code_710
# checked on 2018-03-25
# next check due 2018-09-25 (semi-annually)
$usa = join('|', $usa, 710);
},
# see http://wtng.info/wtng-cod.html#WZ1
# checked 2014-04-21
PR => '787|939',
DO => '809|829|849',
BS => '242',
BB => '246',
AI => '264',
AG => '268',
VG => '284',
VI => '340',
KY => '345',
BM => '441',
GD => '473',
TC => '649',
MS => '664',
MP => '670',
GU => '671',
AS => '684',
SX => '721',
LC => '758',
DM => '767',
VC => '784',
TT => '868',
KN => '869',
JM => '876',
# see https://en.wikipedia.org/wiki/North_American_Numbering_Plan#NANP_countries_and_territories
# checked on 2018-03-23
# next check due 2019-03-01 (annually)
AS => '684', # American Samoa
AI => '264', # Anguilla
AG => '268', # Antigua and Barbude
BS => '242', # Bahamas
BB => '246', # Barbados
BM => '441', # Bermuda
VG => '284', # British Virgin Islands
KY => '345', # Cayman Islands
DM => '767', # Dominica
DO => '809|829|849', # Dominican Republic
GD => '473', # Grenada
GU => '671', # Guam
JM => '876', # Jamaica
MS => '664', # Montserrat
MP => '670', # Northern Mariana Islands
PR => '787|939', # Puerto Rico
KN => '869', # Saint Kitts and Nevis
LC => '758', # Saint Lucia
VC => '784', # Saint Vincent and the Grenadines
SX => '721', # Sint Maarten
TT => '868', # Trinidad and Tobago
TC => '649', # Turks and Caicos Islands
VI => '340', # US Virgin Islands
);
# private sub, returns list of NANP areas for the given ISO country code
......
This diff is collapsed.
......@@ -21,7 +21,7 @@
use strict;
use warnings;
use vars qw(%areanames %fixed_line_regexes %mobile_regexes);
our $VERSION = 1.20180203200229;
our $VERSION = 1.20180410221541;
......@@ -4245,6 +4245,7 @@ our $VERSION = 1.20180203200229;
'1276956' => "Ridgeway\,\ VA",
'1276964' => "Richlands\,\ VA",
'1276988' => "Tazewell\,\ VA",
'1279' => "California",
'1281' => "Texas",
'1281207' => "Sugar\ Land\,\ TX",
'1281208' => "Missouri\ City\,\ TX",
......@@ -36306,7 +36307,7 @@ $fixed_line_regexes{SX} = '7215(?:4[2-8]|8[239]|9[056])\d{4}';
$mobile_regexes{SX} = '7215(?:1[02]|2\d|5[034679]|8[014-8])\d{4}';
$fixed_line_regexes{TC} = '649(?:712|9(?:4\d|50))\d{4}';
$mobile_regexes{TC} = '649(?:2(?:3[129]|4[1-7])|3(?:3[1-389]|4[1-8])|4[34][1-3])\d{4}';
$fixed_line_regexes{TT} = '868(?:2(?:01|[23]\d)|6(?:0[79]|1[02-8]|2[1-9]|[3-69]\d|7[0-79])|82[124])\d{4}';
$fixed_line_regexes{TT} = '868(?:2(?:01|[23]\d)|6(?:0[7-9]|1[02-8]|2[1-9]|[3-69]\d|7[0-79])|82[124])\d{4}';
$mobile_regexes{TT} = '868(?:2(?:6[6-9]|[789]\d)|3(?:0[1-9]|1[02-9]|[2-9]\d)|4[6-9]\d|6(?:20|78|8\d)|7(?:0[1-9]|1[02-9]|[2-9]\d))\d{4}';
$fixed_line_regexes{VC} = '784(?:266|3(?:6[6-9]|7\d|8[0-24-6])|4(?:38|5[0-36-8]|8[0-8])|5(?:55|7[0-2]|93)|638|784)\d{4}';
$mobile_regexes{VC} = '784(?:4(?:3[0-5]|5[45]|89|9[0-58])|5(?:2[6-9]|3[0-4]))\d{4}';
......@@ -22,18 +22,18 @@ use base qw(Number::Phone::StubCountry);
use strict;
use warnings;
use utf8;
our $VERSION = 1.20180203200231;
our $VERSION = 1.20180410221544;
my $formatters = [];
my $validators = {
'mobile' => '4\\d{4}',
'personal_number' => '',
'toll_free' => '',
'fixed_line' => '6[2-467]\\d{3}',
'specialrate' => '([01589]\\d{5})',
'geographic' => '6[2-467]\\d{3}',
'personal_number' => '',
'pager' => '',
'toll_free' => '',
'fixed_line' => '6[2-467]\\d{3}',
'voip' => ''
};
my %areanames = (
......@@ -52,6 +52,6 @@ my %areanames = (
my $number = shift;
$number =~ s/(^\+247|\D)//g;
my $self = bless({ number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
return $self->is_valid() ? $self : undef;
}
return $self->is_valid() ? $self : undef;
}
1;
\ No newline at end of file
......@@ -22,34 +22,37 @@ use base qw(Number::Phone::StubCountry);
use strict;
use warnings;
use utf8;
our $VERSION = 1.20180203200231;
our $VERSION = 1.20180410221544;
my $formatters = [
{
'format' => '$1 $2',
'pattern' => '(\\d{3})(\\d{3})',
'format' => '$1 $2',
'leading_digits' => '
[137-9]|
6[0-8]
'
},
{
'format' => '$1 $2',
'pattern' => '(\\d{4})(\\d{4})',
'format' => '$1 $2',
'leading_digits' => '180[02]'
},
{
'pattern' => '(\\d{3})(\\d{3})(\\d{3})',
'format' => '$1 $2 $3',
'leading_digits' => '690',
'format' => '$1 $2 $3'
'pattern' => '(\\d{3})(\\d{3})(\\d{3})'
}
];
my $validators = {
'voip' => '',
'fixed_line' => '[78]\\d{5}',
'toll_free' => '180[02]\\d{4}',
'pager' => '',
'personal_number' => '',
'geographic' => '[78]\\d{5}',
'specialrate' => '([19]\\d{5})',
'toll_free' => '180[02]\\d{4}',
'fixed_line' => '[78]\\d{5}',
'mobile' => '
(?:
3\\d|
......@@ -58,10 +61,7 @@ my $validators = {
90\\d{2}
)
)\\d{4}
',
'personal_number' => '',
'voip' => '',
'pager' => ''
'
};
sub new {
......@@ -69,6 +69,6 @@ my $validators = {
my $number = shift;
$number =~ s/(^\+376|\D)//g;
my $self = bless({ number => $number, formatters => $formatters, validators => $validators, }, $class);
return $self->is_valid() ? $self : undef;
}
return $self->is_valid() ? $self : undef;
}
1;
\ No newline at end of file
......@@ -22,47 +22,47 @@ use base qw(Number::Phone::StubCountry);
use strict;
use warnings;
use utf8;
our $VERSION = 1.20180203200232;
our $VERSION = 1.20180410221544;
my $formatters = [
{
'format' => '$1 $2 $3',
'national_rule' => '0$1',
'leading_digits' => '[2-4679][2-8]',
'pattern' => '([2-4679])(\\d{3})(\\d{4})',
'national_rule' => '0$1'
'format' => '$1 $2 $3',
'pattern' => '([2-4679])(\\d{3})(\\d{4})'
},
{
'format' => '$1 $2 $3',
'leading_digits' => '5',
'pattern' => '(5\\d)(\\d{3})(\\d{4})',
'national_rule' => '0$1'
'format' => '$1 $2 $3',
'national_rule' => '0$1',
'leading_digits' => '5'
},
{
'format' => '$1 $2 $3',
'leading_digits' => '[479]00',
'pattern' => '([479]00)(\\d)(\\d{5})',
'national_rule' => '$1'
'national_rule' => '$1',
'leading_digits' => '[479]00',
'format' => '$1 $2 $3'
},
{
'national_rule' => '$1',
'pattern' => '([68]00)(\\d{2,9})',
'format' => '$1 $2',
'leading_digits' => '[68]00',
'pattern' => '([68]00)(\\d{2,9})'
'national_rule' => '$1',
'leading_digits' => '[68]00'
}
];
my $validators = {
'mobile' => '5[024-68]\\d{7}',
'personal_number' => '',
'fixed_line' => '[2-4679][2-8]\\d{6}',
'toll_free' => '
400\\d{6}|
800\\d{2,9}
',
'specialrate' => '(700[05]\\d{5})|(900[02]\\d{5})|(600[25]\\d{5})',
'voip' => '',
'geographic' => '[2-4679][2-8]\\d{6}',
'specialrate' => '(700[05]\\d{5})|(900[02]\\d{5})|(600[25]\\d{5})',
'mobile' => '5[024-68]\\d{7}',
'pager' => '',
'voip' => ''
'personal_number' => ''
};
sub new {
......@@ -70,13 +70,9 @@ my $validators = {
my $number = shift;
$number =~ s/(^\+971|\D)//g;
my $self = bless({ number => $number, formatters => $formatters, validators => $validators, }, $class);
return $self if ($self->is_valid());
{
no warnings 'uninitialized';
$number =~ s/^(?:0)//;
}
$number =~ s/^(?:0)//;
$self = bless({ number => $number, formatters => $formatters, validators => $validators, }, $class);
return $self->is_valid() ? $self : undef;
}
return $self->is_valid() ? $self : undef;
}
1;
\ No newline at end of file
......@@ -22,19 +22,19 @@ use base qw(Number::Phone::StubCountry);
use strict;
use warnings;
use utf8;
our $VERSION = 1.20180203200232;
our $VERSION = 1.20180410221544;
my $formatters = [
{
'format' => '$1 $2 $3',
'pattern' => '([2-7]\\d)(\\d{3})(\\d{4})',
'leading_digits' => '[2-7]',
'national_rule' => '0$1'
'format' => '$1 $2 $3',
'national_rule' => '0$1',
'leading_digits' => '[2-7]'
}
];
my $validators = {
'toll_free' => '',
'voip' => '',
'fixed_line' => '
(?:
[25][0-8]|
......@@ -42,7 +42,9 @@ my $validators = {
6[0-5]
)[2-9]\\d{6}
',
'specialrate' => '',
'toll_free' => '',
'pager' => '',
'personal_number' => '',
'geographic' => '
(?:
[25][0-8]|
......@@ -50,16 +52,14 @@ my $validators = {
6[0-5]
)[2-9]\\d{6}
',
'personal_number' => '',
'specialrate' => '',
'mobile' => '
7(?:
[014-9]\\d|
2[89]|
30
3[01]
)\\d{6}
',
'voip' => '',
'pager' => ''
'
};
my %areanames = (
9320 => "Kabul",
......@@ -102,13 +102,9 @@ my %areanames = (
my $number = shift;
$number =~ s/(^\+93|\D)//g;
my $self = bless({ number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
return $self if ($self->is_valid());
{
no warnings 'uninitialized';
$number =~ s/^(?:0)//;
}
$number =~ s/^(?:0)//;
$self = bless({ number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
return $self->is_valid() ? $self : undef;
}
return $self->is_valid() ? $self : undef;
}
1;
\ No newline at end of file
......@@ -22,13 +22,13 @@ use base qw(Number::Phone::StubCountry);
use strict;
use warnings;
use utf8;
our $VERSION = 1.20180203200232;
our $VERSION = 1.20180410221544;
my $formatters = [
{
'intl_format' => 'NA',
'pattern' => '(\\d{3})(\\d{4})',
'format' => '$1-$2'
'format' => '$1-$2',
'pattern' => '(\\d{3})(\\d{4})'
},
{
'pattern' => '(\\d{3})(\\d{3})(\\d{4})',
......@@ -38,9 +38,7 @@ my $formatters = [
];
my $validators = {
'voip' => '26848[01]\\d{4}',
'pager' => '26840[69]\\d{4}',
'fixed_line' => '
'geographic' => '
268(?:
4(?:
6[0-38]|
......@@ -50,26 +48,20 @@ my $validators = {
)\\d{4}
',
'specialrate' => '(900[2-9]\\d{6})',
'toll_free' => '
8(?:
00|
33|
44|
55|
66|
77|
88
)[2-9]\\d{6}
',
'geographic' => '
'mobile' => '
268(?:
4(?:
6[0-38]|
84
)|
56[0-2]
464|
7(?:
1[3-9]|
2\\d|
3[246]|
64|
7[0-689]|
8[02-68]
)
)\\d{4}
',
'pager' => '26840[69]\\d{4}',
'personal_number' => '
5(?:
(?:
......@@ -84,19 +76,27 @@ my $validators = {
21[23]
)\\d{6}
',
'mobile' => '
'fixed_line' => '
268(?:
464|
7(?:
1[3-9]|
2\\d|
3[246]|
64|
7[0-689]|
8[02-68]
)
4(?:
6[0-38]|
84
)|
56[0-2]
)\\d{4}
'
',
'toll_free' => '
8(?:
00|
33|
44|
55|
66|
77|
88
)[2-9]\\d{6}
',
'voip' => '26848[01]\\d{4}'
};
use Number::Phone::NANP::Data;
sub areaname {
......@@ -109,6 +109,6 @@ Number::Phone::NANP::Data::_areaname('1'.shift()->{number}); }
my $number = shift;
$number =~ s/(^\+1|\D)//g;
my $self = bless({ number => $number, formatters => $formatters, validators => $validators, }, $class);
return $self->is_valid() ? $self : undef;
}
return $self->is_valid() ? $self : undef;
}
1;
\ No newline at end of file
......@@ -22,13 +22,13 @@ use base qw(Number::Phone::StubCountry);
use strict;
use warnings;
use utf8;
our $VERSION = 1.20180203200232;
our $VERSION = 1.20180410221544;
my $formatters = [
{
'intl_format' => 'NA',
'pattern' => '(\\d{3})(\\d{4})',
'format' => '$1-$2'
'format' => '$1-$2',
'pattern' => '(\\d{3})(\\d{4})'
},
{
'pattern' => '(\\d{3})(\\d{3})(\\d{4})',
......@@ -38,18 +38,6 @@ my $formatters = [
];
my $validators = {
'geographic' => '
2644(?:
6[12]|
9[78]
)\\d{4}
',
'fixed_line' => '
2644(?:
6[12]|