File Coverage

blib/lib/Dancer2/Plugin/FormValidator/Validator/EmailDns.pm
Criterion Covered Total %
statement 25 26 96.1
branch 3 4 75.0
condition n/a
subroutine 9 9 100.0
pod 0 2 0.0
total 37 41 90.2


line stmt bran cond sub pod time code
1              
2             use strict;
3 2     2   2211 use warnings;
  2         7  
  2         67  
4 2     2   11  
  2         4  
  2         57  
5             use Moo;
6 2     2   15 use utf8;
  2         10  
  2         29  
7 2     2   811 use Email::Valid;
  2         6  
  2         35  
8 2     2   74 use namespace::clean;
  2         6  
  2         47  
9 2     2   14  
  2         2  
  2         21  
10             with 'Dancer2::Plugin::FormValidator::Role::Validator';
11              
12             return {
13             en => '%s is not a valid email',
14             ru => '%s не является валидным email адресом',
15 1     1 0 1226 de => '%s enthält keine gültige E-Mail-Adresse',
16             };
17             }
18              
19             my ($self, $field, $input) = @_;
20              
21             if ($self->_field_defined_and_non_empty($field, $input)) {
22 2     2 0 7 return $self->_is_valid_email_and_dns($input->{$field});
23             }
24 2 50       8  
25 2         8 return 1;
26             }
27              
28 0         0 if (my $valid_email = Email::Valid->address(-address => $_[1], -mxcheck => 1 )) {
29             return $_[1] eq $valid_email;
30             }
31              
32 2 100   2   10 return 0;
33 1         1294440 }
34              
35             1;