lib/Badger/Data/Facet/List/MaxSize.pm | |||
---|---|---|---|
Criterion | Covered | Total | % |
statement | 5 | 5 | 100.0 |
branch | 2 | 2 | 100.0 |
condition | 1 | 2 | 50.0 |
subroutine | 2 | 2 | 100.0 |
pod | 1 | 1 | 100.0 |
total | 11 | 12 | 91.6 |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | package Badger::Data::Facet::List::MaxSize; | ||||||
2 | |||||||
3 | use Badger::Data::Facet::Class | ||||||
4 | 1 | 10 | version => 0.01, | ||||
5 | type => 'list', | ||||||
6 | 1 | 1 | 6 | args => 'max_size'; | |||
1 | 1 | ||||||
7 | |||||||
8 | |||||||
9 | sub validate { | ||||||
10 | 3 | 3 | 1 | 5 | my ($self, $value, $type) = @_; | ||
11 | |||||||
12 | return scalar(@$value) <= $self->{ max_size } | ||||||
13 | ? $value | ||||||
14 | : $self->invalid_msg( | ||||||
15 | 3 | 100 | 50 | 15 | too_many => $type || 'List', $self->{ max_size }, scalar(@$value) | ||
16 | ); | ||||||
17 | |||||||
18 | } | ||||||
19 | |||||||
20 | 1; | ||||||
21 | |||||||
22 | __END__ |