File Coverage

blib/lib/Dancer2/Plugin/FormValidator/Extension/DBIC/Unique.pm
Criterion Covered Total %
statement 15 20 75.0
branch 0 2 0.0
condition n/a
subroutine 5 7 71.4
pod 0 2 0.0
total 20 31 64.5


line stmt bran cond sub pod time code
1              
2             use strict; use warnings;
3 1     1   1060  
  1     1   2  
  1         25  
  1         4  
  1         2  
  1         22  
4             use Moo;
5 1     1   4 use utf8;
  1         3  
  1         4  
6 1     1   780 use namespace::clean;
  1         13  
  1         6  
7 1     1   28  
  1         3  
  1         7  
8             with 'Dancer2::Plugin::FormValidator::Role::Validator';
9              
10             return {
11             en => '%s is already exists',
12             ru => '%s уже существует',
13 0     0 0   de => '%s ist bereits vorhanden',
14             };
15             }
16              
17             my ($self, $field, $input, $source, $attribute) = @_;
18              
19             if ($self->_field_defined_and_non_empty($field, $input)) {
20 0     0 0   return not $self->extension->schema->resultset($source)->single(
21             {
22 0 0         $attribute => $input->{$field},
23             }
24             );
25 0           }
26              
27             return 1;
28             }
29              
30 0           1;