nipotan / p5-number-phone-jp Goto Github PK
View Code? Open in Web Editor NEWValidate Japanese phone numbers
Home Page: http://search.cpan.org/dist/Number-Phone-JP/
Validate Japanese phone numbers
Home Page: http://search.cpan.org/dist/Number-Phone-JP/
Hi nipotan,
Wesley here,
I recently joined the 2015 cpan pull request challenge and was assigned to this module.
So, I went in to check MetaCpan regarding your module for any outstanding bugs.
It pointed me to this, here's the report
I believe the dependency for Number::Phone was not declared in a metacpan friendly manner, ie. requiring either a meta.yml
or meta.json
file. see this
I've forked the repo and will submit a pull request for meta.json.
Do you have any more suggestions?
(maybe you can take a look at this, a list of suggestions from the organisers)
Number-Phone-JP uses Module::Install as an module installer. But now it is discouraged because:
.
in @INC
, but perl 5.26 removes .
from @INC
. So, if people install your modules, they may need to append .
to @INC
manually.Why don't you switch Module::Install to another module maker?
Although you can use ExtUtils::MakeMaker or Module::Build directly,
I would suggest to use authoring tools such as Dist::Zilla, Dist::Milla or Minilla.
the newest data is updated on 2021/04/20.
https://www.soumu.go.jp/main_sosiki/joho_tsusin/top/tel_number/number_shitei.html
It seems some numbers were added especially for mobile phones like 070~
Is this just a problem of that one?
https://github.com/nipotan/p5-Number-Phone-JP/blob/master/lib/Number/Phone/JP/Table/Mobile.pm
I have made my validation routine like below:
sub optimize {
my $phone = shift;
$phone = alnum_z2h($phone); # 全角数字を半角に
$phone =~ s/[^\d\-\s]+/ /g; # 関係ない文字の削除
$phone =~ s/[\s\-]+/ /g; # デリミタを統一
return '電話番号をもう一度確認してください。'
unless Number::Phone::JP->new->set_number($phone)->is_valid();
return $phone;
}
But it returns message with some warn like below:
The number is invalid telephone number. at xxxx.pl line xx.
Any number was not set at xxxx.pl line xx.
電話番号をもう一度確認してください。
It seems that numbers with no space( /^\d+$/ ) return same errors.
the full of my test code is here:
use feature qw(say);
use strict;
use warnings;
use utf8;
use Lingua::JA::Regular::Unicode qw(alnum_z2h);
use Number::Phone::JP qw(Freedial);
binmode STDOUT,':utf8';
binmode STDERR, ':utf8';
my $do_divide = 0;
my $phone = optimize('0120893893'); # 全角数字(ハイフン無し)
say $phone; # 0120 893 893 を期待
#The number is invalid telephone number. at test.pl line 36.
#Any number was not set at test.pl line 36.
#電話番号をもう一度確認してください。
say optimize('0120893893'); # 半角数字でも同じ結果
say optimize('0120 893 893'); # スペースを入れると解決
$do_divide = 1; # またはスペースを挿入する処理を呼び出す
say optimize('0120893893'); # と解決
exit;
sub optimize {
my $phone = shift;
$phone = alnum_z2h($phone); # 全角数字を半角に
$phone =~ s/[^\d\-\s]+/ /g; # 関係ない文字の削除
$phone =~ s/[\s\-]+/ /g; # デリミタを統一
if( $do_divide and $phone !~ / / ) { # 連番を分離する
$phone =~ /^0120(\d{3})(\d{3})$/;
$phone = "0120 $1 $2";
}
return '電話番号をもう一度確認してください。'
unless Number::Phone::JP->new->set_number($phone)->is_valid();
return $phone;
}
Does it deserve to write a PR?
and thus it does not show up on MetaCPAN either. It is strange as I can see the code in the Makefile.PL
file.
Looking again, I see META.json
is commited to git (and it should not as it is a generated file) and it is probably not re-generated on release so the information from Makefile.PL
did not make it into the package.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.