File Coverage

blib/lib/Dancer2/Plugin/FormValidator/Validator/Accepted.pm
Criterion Covered Total %
statement 23 24 95.8
branch 1 2 50.0
condition n/a
subroutine 9 9 100.0
pod 0 2 0.0
total 33 37 89.1


line stmt bran cond sub pod time code
1              
2             use strict;
3 2     2   91912 use warnings;
  2         6  
  2         46  
4 2     2   7  
  2         4  
  2         37  
5             use Moo;
6 2     2   381 use utf8;
  2         5100  
  2         7  
7 2     2   1534 use List::Util qw(any);
  2         3  
  2         20  
8 2     2   46 use namespace::clean;
  2         3  
  2         135  
9 2     2   349  
  2         9709  
  2         15  
10             with 'Dancer2::Plugin::FormValidator::Role::Validator';
11              
12             return {
13             en => '%s must be accepted',
14             ru => '%s должно быть выбрано',
15 1     1 0 1647 de => '%s muss markiert sein',
16             };
17             }
18              
19             around 'stop_on_fail' => sub {
20             return 1;
21             };
22              
23             my ($self, $field, $input) = @_;
24              
25             if (exists $input->{$field}) {
26 5     5 0 11 return any { $input->{$field} eq $_ } qw(yes on 1);
27             }
28 5 50       14  
29 5     12   27 return 0;
  12         44  
30             }
31              
32 0           1;