| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Vparam::ISIN; |
|
2
|
73
|
|
|
73
|
|
5335969
|
use Mojo::Base -strict; |
|
|
73
|
|
|
|
|
103846
|
|
|
|
73
|
|
|
|
|
434
|
|
|
3
|
73
|
|
|
73
|
|
8811
|
use Mojolicious::Plugin::Vparam::Common qw(char_shift); |
|
|
73
|
|
|
|
|
138
|
|
|
|
73
|
|
|
|
|
51249
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub check_isin($) { |
|
6
|
10
|
50
|
|
10
|
0
|
15
|
return 'Value not defined' unless defined $_[0]; |
|
7
|
10
|
100
|
|
|
|
28
|
return 'Value not set' unless length $_[0]; |
|
8
|
9
|
50
|
|
|
|
64
|
return 'Wrong format' unless $_[0] =~ m{^[A-Z0-9]+$}; |
|
9
|
|
|
|
|
|
|
|
|
10
|
9
|
|
|
|
|
16
|
my $str = $_[0]; |
|
11
|
9
|
|
|
|
|
14
|
my $ch = char_shift(); |
|
12
|
9
|
|
|
|
|
25
|
s{([A-Z])}{(ord($1)-$ch)}eg for $str; |
|
|
15
|
|
|
|
|
42
|
|
|
13
|
9
|
|
|
|
|
11
|
my $crc = 0; |
|
14
|
9
|
|
|
|
|
37
|
my @str = reverse split '', $str; |
|
15
|
9
|
|
|
|
|
19
|
for my $i ( 0 .. $#str ) { |
|
16
|
130
|
|
|
|
|
122
|
my $digit = $str[$i]; |
|
17
|
130
|
100
|
|
|
|
162
|
$digit *= 2 if $i % 2; |
|
18
|
130
|
100
|
|
|
|
148
|
$digit -= 9 if $digit > 9; |
|
19
|
130
|
|
|
|
|
127
|
$crc += $digit; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
9
|
100
|
|
|
|
19
|
return 'Checksum error' if $crc % 10; |
|
22
|
|
|
|
|
|
|
|
|
23
|
8
|
|
|
|
|
27
|
return 0; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub check_maestro { |
|
27
|
3
|
50
|
|
3
|
0
|
8
|
return 'Value not defined' unless defined $_[0]; |
|
28
|
3
|
100
|
|
|
|
17
|
return 'Value not set' unless length $_[0]; |
|
29
|
2
|
50
|
|
|
|
67
|
return 'Wrong format' unless $_[0] =~ m{^\d+$}; |
|
30
|
|
|
|
|
|
|
|
|
31
|
2
|
|
|
|
|
9
|
return 0; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub check_creditcard { |
|
35
|
5
|
50
|
|
5
|
0
|
10
|
return 'Value not defined' unless defined $_[0]; |
|
36
|
5
|
100
|
|
|
|
16
|
return 'Value not set' unless length $_[0]; |
|
37
|
4
|
100
|
|
|
|
22
|
return 'Wrong format' unless $_[0] =~ m{^\d+$}; |
|
38
|
|
|
|
|
|
|
|
|
39
|
2
|
|
|
|
|
6
|
return 0; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub parse_isin($) { |
|
43
|
15
|
|
|
15
|
0
|
27
|
my ($str) = @_; |
|
44
|
15
|
50
|
|
|
|
24
|
return undef unless defined $str; |
|
45
|
15
|
|
|
|
|
65
|
s{[^a-zA-Z0-9]}{}g for $str; |
|
46
|
15
|
|
|
|
|
46
|
return uc $str; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub parse_maestro($) { |
|
50
|
3
|
|
|
3
|
0
|
7
|
my ($str) = @_; |
|
51
|
3
|
50
|
|
|
|
10
|
return undef unless defined $str; |
|
52
|
3
|
|
|
|
|
25
|
s{\D+}{}g for $str; |
|
53
|
3
|
|
|
|
|
9
|
return $str; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub parse_creditcard($) { |
|
57
|
5
|
|
|
5
|
0
|
10
|
return parse_isin $_[0]; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub register { |
|
61
|
75
|
|
|
75
|
0
|
224
|
my ($class, $self, $app, $conf) = @_; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$app->vtype( |
|
64
|
|
|
|
|
|
|
isin => |
|
65
|
10
|
|
|
10
|
|
16
|
pre => sub { parse_isin $_[1] }, |
|
66
|
10
|
|
|
10
|
|
17
|
valid => sub { check_isin $_[1] }, |
|
67
|
75
|
|
|
|
|
775
|
); |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$app->vtype( |
|
70
|
|
|
|
|
|
|
maestro => |
|
71
|
3
|
|
|
3
|
|
13
|
pre => sub { parse_maestro $_[1] }, |
|
72
|
3
|
|
|
3
|
|
11
|
valid => sub { check_maestro $_[1] }, |
|
73
|
75
|
|
|
|
|
640
|
); |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$app->vtype( |
|
76
|
|
|
|
|
|
|
creditcard => |
|
77
|
5
|
|
|
5
|
|
13
|
pre => sub { parse_creditcard $_[1] }, |
|
78
|
5
|
|
|
5
|
|
10
|
valid => sub { check_creditcard $_[1] }, |
|
79
|
75
|
|
|
|
|
570
|
); |
|
80
|
|
|
|
|
|
|
|
|
81
|
75
|
|
|
|
|
267
|
return; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |