line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Widget::Constraint::In; |
2
|
88
|
|
|
88
|
|
70825
|
use base 'HTML::Widget::Constraint'; |
|
88
|
|
|
|
|
198
|
|
|
88
|
|
|
|
|
7420
|
|
3
|
|
|
|
|
|
|
|
4
|
88
|
|
|
88
|
|
557
|
use strict; |
|
88
|
|
|
|
|
171
|
|
|
88
|
|
|
|
|
2558
|
|
5
|
88
|
|
|
88
|
|
453
|
use warnings; |
|
88
|
|
|
|
|
208
|
|
|
88
|
|
|
|
|
20104
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw/in/); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
HTML::Widget::Constraint::In - Check that a value is one of a current set. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$widget->constraint( In => "foo" )->in(qw/possible values/); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 METHODS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head2 validate |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub validate { |
27
|
11
|
|
|
11
|
1
|
19
|
my ( $self, $value ) = @_; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Return valid on an empty value |
30
|
11
|
100
|
|
|
|
35
|
return 1 unless defined($value); |
31
|
10
|
100
|
|
|
|
304
|
return 1 if ( $value eq '' ); |
32
|
|
|
|
|
|
|
|
33
|
9
|
|
|
|
|
31
|
my $in = $self->in; |
34
|
|
|
|
|
|
|
|
35
|
9
|
100
|
|
|
|
142
|
my %in = map { $_ => 1 } ref $in ? @{ $self->in } : $in; |
|
23
|
|
|
|
|
103
|
|
|
8
|
|
|
|
|
24
|
|
36
|
|
|
|
|
|
|
|
37
|
9
|
|
|
|
|
199
|
return exists $in{$value}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 in |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Arguments: @values |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
A list of valid values for that element. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|