line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::CheckArgs::option; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base 'HTML::CheckArgs::Object'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1051
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub is_valid { |
9
|
7
|
|
|
7
|
0
|
7
|
my $self = shift; |
10
|
|
|
|
|
|
|
|
11
|
7
|
|
|
|
|
20
|
my $value = $self->value; |
12
|
7
|
|
|
|
|
19
|
my $config = $self->config; |
13
|
|
|
|
|
|
|
|
14
|
7
|
|
|
|
|
30
|
$self->check_params( required => [ qw( options ) ], optional => [], cleanable => 0 ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# no value passed in |
17
|
6
|
100
|
100
|
|
|
41
|
if ( $config->{required} && !$value ) { |
|
|
100
|
100
|
|
|
|
|
18
|
1
|
|
|
|
|
8
|
$self->error_code( 'option_00' ); # required |
19
|
1
|
|
|
|
|
15
|
$self->error_message( 'Not given.' ); |
20
|
1
|
|
|
|
|
7
|
return; |
21
|
|
|
|
|
|
|
} elsif ( !$config->{required} && !$value ) { |
22
|
1
|
|
|
|
|
3
|
return 1; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# check if valid option |
26
|
4
|
|
|
|
|
6
|
my @options = @{ $config->{params}{options} }; |
|
4
|
|
|
|
|
9
|
|
27
|
4
|
100
|
|
|
|
9
|
unless ( grep { $value eq $_ } @options ) { |
|
8
|
|
|
|
|
19
|
|
28
|
2
|
|
|
|
|
7
|
$self->error_code( 'option_01' ); # not valid value |
29
|
2
|
|
|
|
|
4
|
$self->error_message( 'Not a valid value.' ); |
30
|
2
|
|
|
|
|
7
|
return; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
8
|
return 1; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |