lib/Badger/Data/Facet/Text/Pattern.pm | |||
---|---|---|---|
Criterion | Covered | Total | % |
statement | 6 | 6 | 100.0 |
branch | n/a | ||
condition | 4 | 6 | 66.6 |
subroutine | 2 | 2 | 100.0 |
pod | 1 | 1 | 100.0 |
total | 13 | 15 | 86.6 |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | package Badger::Data::Facet::Text::Pattern; | ||||||
2 | |||||||
3 | use Badger::Data::Facet::Class | ||||||
4 | 1 | 8 | version => 0.01, | ||||
5 | type => 'text', | ||||||
6 | 1 | 1 | 5 | args => 'pattern'; | |||
1 | 2 | ||||||
7 | |||||||
8 | |||||||
9 | sub validate { | ||||||
10 | 2 | 2 | 1 | 5 | my ($self, $text, $type) = @_; | ||
11 | 2 | 66 | 58 | my $regex = $self->{ regex } ||= qr/$self->{ pattern }/; | |||
12 | |||||||
13 | return $$text =~ $regex | ||||||
14 | || $self->invalid_msg( | ||||||
15 | 2 | 66 | 24 | pattern => $type || 'Text', $self->{ pattern }, $$text | |||
16 | ); | ||||||
17 | } | ||||||
18 | |||||||
19 | |||||||
20 | 1; | ||||||
21 | |||||||
22 | __END__ |