line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Valiemon::Attributes::Pattern; |
2
|
3
|
|
|
3
|
|
1512
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
78
|
|
3
|
3
|
|
|
3
|
|
10
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
64
|
|
4
|
3
|
|
|
3
|
|
9
|
use utf8; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
11
|
|
5
|
3
|
|
|
3
|
|
431
|
use parent qw(Valiemon::Attributes); |
|
3
|
|
|
|
|
317
|
|
|
3
|
|
|
|
|
11
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
152
|
use Carp qw(croak); |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
476
|
|
8
|
|
|
|
|
|
|
|
9
|
13
|
|
|
13
|
0
|
26
|
sub attr_name { 'pattern' } |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub is_valid { |
12
|
18
|
|
|
18
|
0
|
24
|
my ($class, $context, $schema, $data) = @_; |
13
|
|
|
|
|
|
|
|
14
|
18
|
100
|
|
|
|
38
|
return 1 unless $context->prims->is_string($data); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$context->in_attr($class, sub { |
17
|
13
|
|
|
13
|
|
15
|
my $pattern = $schema->{pattern}; |
18
|
|
|
|
|
|
|
|
19
|
13
|
100
|
|
|
|
22
|
unless ($context->prims->is_string($pattern)) { |
20
|
2
|
|
|
|
|
6
|
croak sprintf '`pattern` must be a string at %s', $context->position |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
11
|
100
|
|
|
|
141
|
$data =~ /$pattern/ ? 1 : 0; |
24
|
13
|
|
|
|
|
54
|
}); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |