FormValidator/Validator/EmailDns.pm

filter: Statementstmt 96.4% 27 / 28 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 2 totaltotal 90.7% 39 / 43 CC 3 SCAR 3.3
CC
3
Cov
94%
validate
2.1
_is_valid_email_and_dns
2.0
BEGIN
1.0
CRAP 1.4
« FormValidator/Validator/Email.pm ↑ Summary FormValidator/Validator/Enum.pm »
1 package Dancer2::Plugin::FormValidator::Validator::EmailDns;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Email::Valid;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 with 'Dancer2::Plugin::FormValidator::Role::Validator';
12  
13 sub message {
14 return {
15 1 ▶ en => '%s is not a valid email',
Subroutine message: called CC=1 SCAR=0.0
Pod undocumented
16 ru => '%s не является валидным email адресом',
17 de => '%s enthält keine gültige E-Mail-Adresse',
18 };
19 }
20  
21 sub validate {
22 2 ▶ my ($self, $field, $input) = @_;
Subroutine validate: called CC=2 SCAR=7.6
Pod undocumented
23  
24 2 ▶ if ($self->_field_defined_and_non_empty($field, $input)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_field_defined_and_non_empty($field, $input)) 2 0 2
25 2 return $self->_is_valid_email_and_dns($input->{$field});
26 }
27  
28 0 return 1;
29 }
30  
31 sub _is_valid_email_and_dns {
32 2 ▶ if (my $valid_email = Email::Valid->address(-address => $_[1], -mxcheck => 1 )) {
Subroutine _is_valid_email_and_dns: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if (my $valid_email = "Email::Valid"->address("-address", $_[1], "-mxcheck", 1)) 1 1 2
33 1 return $_[1] eq $valid_email;
34 }
35  
36 1 return 0;
37 }
38  
39 2 1;
« FormValidator/Validator/Email.pm ↑ Summary FormValidator/Validator/Enum.pm »