| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTML::Widget::Constraint::Regex; |
|
2
|
|
|
|
|
|
|
|
|
3
|
88
|
|
|
88
|
|
666
|
use warnings; |
|
|
88
|
|
|
|
|
203
|
|
|
|
88
|
|
|
|
|
2765
|
|
|
4
|
88
|
|
|
88
|
|
484
|
use strict; |
|
|
88
|
|
|
|
|
190
|
|
|
|
88
|
|
|
|
|
2562
|
|
|
5
|
88
|
|
|
88
|
|
546
|
use base 'HTML::Widget::Constraint'; |
|
|
88
|
|
|
|
|
180
|
|
|
|
88
|
|
|
|
|
56846
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw/regex/); |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
HTML::Widget::Constraint::Regex - Regex Constraint |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $c = $widget->constraint( 'Regex', 'foo' ); |
|
16
|
|
|
|
|
|
|
$c->regex(qr/^\w+$/); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Regex Constraint. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
The Regex constraint always allows an C value or an empty string. |
|
23
|
|
|
|
|
|
|
If you don't want this behaviour, also use the |
|
24
|
|
|
|
|
|
|
L. |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 METHODS |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 regex |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Arguments: qr/ regex / |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 validate |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub validate { |
|
37
|
129
|
|
|
129
|
1
|
683
|
my ( $self, $value ) = @_; |
|
38
|
129
|
|
33
|
|
|
478
|
my $regex = $self->regex || qr/.*/; |
|
39
|
129
|
100
|
100
|
|
|
2219
|
return 0 if ( defined $value |
|
|
|
|
100
|
|
|
|
|
|
40
|
|
|
|
|
|
|
&& $value ne '' |
|
41
|
|
|
|
|
|
|
&& $value !~ $regex ); |
|
42
|
79
|
|
|
|
|
453
|
return 1; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 AUTHOR |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Sebastian Riedel, C |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 LICENSE |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify it under |
|
52
|
|
|
|
|
|
|
the same terms as Perl itself. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |