-
Notifications
You must be signed in to change notification settings - Fork 4
Constraint telephone
Yuki Kimoto edited this page May 19, 2015
·
6 revisions
Check Telephone number very loose.
my $data = {tel => '123-456-789'};
my $rule = $vc->create_rule;
$rule->require('tel')->check('telephone_loose');
Constraint
telephone_loose => sub { $_[0] =~ /^[\d-]+$/ },
Telephone consist of "-" or number.
Check Telephone number by Number::Phone::JP
my $data = {tel => '123-456-789'};
my $rule = $vc->create_rule;
$rule->require('tel')->check('telephone_japanese');
Constraint
telephone_japanese => sub {
use Number::Phone::JP qw/mobile PHS/;
return 0 unless $_[0];
return Number::Phone::JP->new($_[0])->is_valid_number ? 1 : 0;
},