| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package FormValidator::Simple::Plugin::Japanese; |
|
2
|
2
|
|
|
2
|
|
1023446
|
use strict; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
89
|
|
|
3
|
2
|
|
|
|
|
2317
|
use base qw/ |
|
4
|
|
|
|
|
|
|
FormValidator::Simple::Plugin::Number::Phone::JP |
|
5
|
2
|
|
|
2
|
|
13
|
/; |
|
|
2
|
|
|
|
|
4
|
|
|
6
|
2
|
|
|
2
|
|
709411
|
use FormValidator::Simple::Exception; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
23
|
|
|
7
|
2
|
|
|
2
|
|
47
|
use FormValidator::Simple::Constants; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
118
|
|
|
8
|
2
|
|
|
2
|
|
1879
|
use Unicode::RecursiveDowngrade; |
|
|
2
|
|
|
|
|
6062
|
|
|
|
2
|
|
|
|
|
34
|
|
|
9
|
2
|
|
|
2
|
|
1769
|
use Mail::Address::MobileJp; |
|
|
2
|
|
|
|
|
1842
|
|
|
|
2
|
|
|
|
|
179
|
|
|
10
|
2
|
|
|
2
|
|
1796
|
use Jcode; |
|
|
2
|
|
|
|
|
52323
|
|
|
|
2
|
|
|
|
|
2394
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# plugin specific method |
|
15
|
|
|
|
|
|
|
sub __japanese_check_charset { |
|
16
|
8
|
|
|
8
|
|
11
|
my ($self, $charset) = @_; |
|
17
|
8
|
|
|
|
|
38
|
my @charsets = ( |
|
18
|
|
|
|
|
|
|
[qw/UTF-8 utf8 utf8/], |
|
19
|
|
|
|
|
|
|
[qw/EUC-JP euc euc /], |
|
20
|
|
|
|
|
|
|
[qw/Shift_JIS shiftjis sjis/], |
|
21
|
|
|
|
|
|
|
); |
|
22
|
8
|
|
|
|
|
14
|
foreach my $set ( @charsets ) { |
|
23
|
8
|
|
|
|
|
11
|
foreach my $name ( @$set ) { |
|
24
|
16
|
100
|
|
|
|
65
|
if( $charset eq $name ) { |
|
25
|
8
|
|
|
|
|
33
|
return $set->[2]; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
FormValidator::Simple::Exception->throw( |
|
30
|
0
|
|
|
|
|
0
|
qq/wrong charset "$charset"./ |
|
31
|
|
|
|
|
|
|
); |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# plugin specific method |
|
35
|
|
|
|
|
|
|
sub __japanese_encode2euc { |
|
36
|
8
|
|
|
8
|
|
9
|
my ($self, $value) = @_; |
|
37
|
8
|
|
50
|
|
|
25
|
my $charset = $self->options->{charset} || 'utf8'; |
|
38
|
8
|
|
|
|
|
90
|
$charset = $self->__japanese_check_charset($charset); |
|
39
|
|
|
|
|
|
|
|
|
40
|
8
|
|
|
|
|
36
|
my $rd = Unicode::RecursiveDowngrade->new; |
|
41
|
8
|
|
|
8
|
|
66
|
$rd->filter( sub { Jcode->new($value, $charset)->euc } ); |
|
|
8
|
|
|
|
|
327
|
|
|
42
|
8
|
|
|
|
|
72
|
return $rd->downgrade($value); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# plugin specific method |
|
46
|
|
|
|
|
|
|
sub __japanese_delete_sp { |
|
47
|
4
|
|
|
4
|
|
7
|
my ($self, $value) = @_; |
|
48
|
4
|
|
|
|
|
18
|
$value = $self->__japanese_encode2euc($value); |
|
49
|
4
|
|
|
|
|
439
|
$value =~ s/ //g; |
|
50
|
4
|
|
|
|
|
6
|
my $ascii = '[\x00-\x7F]'; |
|
51
|
4
|
|
|
|
|
4
|
my $two_bytes = '[\x8E\xA1-\xFE][\xA1-\xFE]'; |
|
52
|
4
|
|
|
|
|
5
|
my $three_bytes = '\x8F[\xA1-\xFE][\xA1-\xFE]'; |
|
53
|
4
|
|
|
|
|
58
|
$value =~ s/\G((?:$ascii|$two_bytes|$three_bytes)*?)(?:\xA1\xA1)/$1/g; |
|
54
|
4
|
|
|
|
|
10
|
return $value; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub HIRAGANA { |
|
58
|
2
|
|
|
2
|
1
|
5959
|
my ($self, $params, $args) = @_; |
|
59
|
2
|
|
|
|
|
14
|
my $value = $self->__japanese_delete_sp( $params->[0] ); |
|
60
|
2
|
100
|
|
|
|
18
|
return $value =~ /^(?:\xA4[\x00-\xFF]|\xA1\xBC)+$/ ? TRUE : FALSE; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub KATAKANA { |
|
64
|
2
|
|
|
2
|
1
|
2733
|
my ($self, $params, $args) = @_; |
|
65
|
2
|
|
|
|
|
6
|
my $value = $self->__japanese_delete_sp( $params->[0] ); |
|
66
|
2
|
100
|
|
|
|
15
|
return $value =~ /^(?:\xA5[\x00-\xFF]|\xA1\xBC)+$/ ? TRUE : FALSE; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub JLENGTH { |
|
70
|
4
|
|
|
4
|
1
|
3287
|
my ($self, $params, $args) = @_; |
|
71
|
4
|
|
50
|
|
|
13
|
my $min = $args->[0] || 0; |
|
72
|
4
|
|
100
|
|
|
17
|
my $max = $args->[1] || 0; |
|
73
|
4
|
|
|
|
|
13
|
my $value = $self->__japanese_encode2euc( $params->[0] ); |
|
74
|
4
|
|
|
|
|
380
|
my $length = Jcode->new($value, 'euc')->jlength; |
|
75
|
4
|
|
66
|
|
|
227
|
$min += 0; $max += 0; $max ||= $min; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
13
|
|
|
76
|
4
|
100
|
100
|
|
|
24
|
return ($min <= $length and $length <= $max) ? TRUE : FALSE; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub ZIP_JP { |
|
80
|
3
|
|
|
3
|
1
|
737
|
my ($self, $params, $args) = @_; |
|
81
|
3
|
100
|
|
|
|
12
|
if ( scalar(@$params) == 1 ) { |
|
|
|
50
|
|
|
|
|
|
|
82
|
2
|
50
|
|
|
|
15
|
return $params->[0] =~ /^\d{3}\-{0,1}\d{4}$/ ? TRUE : FALSE; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
elsif ( scalar(@$params) == 2 ) { |
|
85
|
1
|
50
|
33
|
|
|
17
|
return ( $params->[0] =~ /^\d{3}$/ && $params->[1] =~ /^\d{4}$/ ) ? TRUE : FALSE; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
else { |
|
88
|
0
|
|
|
|
|
0
|
FormValidator::Simple::Exception->throw( |
|
89
|
|
|
|
|
|
|
qq/wrong format for 'ZIP_JP'./ |
|
90
|
|
|
|
|
|
|
); |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub EMAIL_MOBILE_JP { |
|
95
|
4
|
|
|
4
|
1
|
3210
|
my ($self, $params, $args) = @_; |
|
96
|
4
|
100
|
|
|
|
8
|
if ( @$args == 0 ) { |
|
97
|
1
|
50
|
|
|
|
8
|
return Mail::Address::MobileJp::is_mobile_jp( $params->[0] ) |
|
98
|
|
|
|
|
|
|
? TRUE : FALSE; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
else { |
|
101
|
3
|
|
|
|
|
5
|
my $ok = 0; |
|
102
|
3
|
|
|
|
|
6
|
foreach my $career ( @$args ) { |
|
103
|
4
|
100
|
|
|
|
42
|
if ( lc($career) eq 'imode' ) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
104
|
1
|
50
|
|
|
|
6
|
if ( Mail::Address::MobileJp::is_imode( $params->[0] ) ) { |
|
105
|
0
|
|
|
|
|
0
|
$ok = 1; |
|
106
|
0
|
|
|
|
|
0
|
last; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
elsif ( lc($career) eq 'ezweb' ) { |
|
110
|
1
|
50
|
|
|
|
4
|
if ( Mail::Address::MobileJp::is_ezweb( $params->[0] ) ) { |
|
111
|
0
|
|
|
|
|
0
|
$ok = 1; |
|
112
|
0
|
|
|
|
|
0
|
last; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
elsif ( lc($career) eq 'vodafone' ) { |
|
116
|
1
|
50
|
|
|
|
5
|
if ( Mail::Address::MobileJp::is_vodafone( $params->[0] ) ) { |
|
117
|
1
|
|
|
|
|
14
|
$ok = 1; |
|
118
|
1
|
|
|
|
|
2
|
last; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
elsif ( lc($career) eq 'softbank' ) { |
|
122
|
1
|
50
|
|
|
|
4
|
if ( Mail::Address::MobileJp::is_softbank( $params->[0] ) ) { |
|
123
|
1
|
|
|
|
|
15
|
$ok = 1; |
|
124
|
1
|
|
|
|
|
2
|
last; |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
else { |
|
128
|
0
|
|
|
|
|
0
|
FormValidator::Simple::Exception->throw( |
|
129
|
|
|
|
|
|
|
qq/Unknown type of mail address./ |
|
130
|
|
|
|
|
|
|
); |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
} |
|
133
|
3
|
100
|
|
|
|
24
|
return $ok ? TRUE : FALSE; |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; |
|
138
|
|
|
|
|
|
|
__END__ |