DBIC/Exist.pm untested

filter: Statementstmt 0.0% 0 / 23 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 34 CC 2 SCAR 11.0
CC
2
Cov
0%
validate
6.0
message
2.0
BEGIN
2.0
CRAP 3.0
1 package Dancer2::Plugin::FormValidator::Extension::DBIC::Exist;
2  
3 use strict; use warnings;
4  
5 use Moo;
6 use utf8;
7 use namespace::clean;
8  
9 with 'Dancer2::Plugin::FormValidator::Role::Validator';
10  
11 sub message {
12 return {
13 en => '%s does not exists',
14 ru => '%s не существует',
15 de => '%s existiert nicht',
16 };
17 }
18  
19 sub validate {
20 my ($self, $field, $input, $source, $attribute) = @_;
21  
22 if ($self->_field_defined_and_non_empty($field, $input)) {
23 return !!$self->extension->schema->resultset($source)->single(
24 {
25 $attribute => $input->{$field},
26 }
27 );
28 }
29  
30 return 1;
31 }
32  
33 1;