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   133011 use warnings;
  2         7  
  2         49  
4 2     2   10  
  2         2  
  2         40  
5             use Moo;
6 2     2   440 use utf8;
  2         6035  
  2         8  
7 2     2   1538 use List::Util qw(any);
  2         5  
  2         26  
8 2     2   52 use namespace::clean;
  2         4  
  2         125  
9 2     2   429  
  2         10500  
  2         11  
10             with 'Dancer2::Plugin::FormValidator::Role::Validator';
11              
12             return {
13             en => '%s must be accepted',
14             ru => '%s должно быть выбрано',
15 1     1 0 1228 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 13 return any { $input->{$field} eq $_ } qw(yes on 1);
27             }
28 5 50       14  
29 5     12   26 return 0;
  12         51  
30             }
31              
32 0           1;