File Coverage

blib/lib/Dancer2/Plugin/FormValidator/Validator/Email.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 12     12   5902 use warnings;
  12         26  
  12         298  
4 12     12   52  
  12         25  
  12         236  
5             use Moo;
6 12     12   47 use utf8;
  12         23  
  12         60  
7 12     12   3443 use Email::Valid;
  12         22  
  12         77  
8 12     12   5024 use namespace::clean;
  12         874575  
  12         1051  
9 12     12   187  
  12         69  
  12         305  
10             with 'Dancer2::Plugin::FormValidator::Role::Validator';
11              
12             return {
13             en => '%s is not a valid email',
14             ru => '%s не является валидным email адресом',
15 5     5 0 1154 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 14     14 0 94 return $self->_is_valid_email($input->{$field});
23             }
24 14 50       133  
25 14         116 return 1;
26             }
27              
28 0         0 if (my $valid_email = Email::Valid->address($_[1])) {
29             return $_[1] eq $valid_email;
30             }
31              
32 14 100   14   141 return 0;
33 5         6577 }
34              
35             1;