FormValidator/Validator/Email.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
2.0
BEGIN
1.0
CRAP 1.4
« FormValidator/Processor.pm ↑ Summary FormValidator/Validator/EmailDns.pm »
1 package Dancer2::Plugin::FormValidator::Validator::Email;
2  
3 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 12 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 12 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 12 ▶use Email::Valid;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 12 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 12 with 'Dancer2::Plugin::FormValidator::Role::Validator';
12  
13 sub message {
14 return {
15 5 ▶ 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 14 ▶ my ($self, $field, $input) = @_;
Subroutine validate: called CC=2 SCAR=7.6
Pod undocumented
23  
24 14 ▶ if ($self->_field_defined_and_non_empty($field, $input)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_field_defined_and_non_empty($field, $input)) 14 0 14
25 14 return $self->_is_valid_email($input->{$field});
26 }
27  
28 0 return 1;
29 }
30  
31 sub _is_valid_email {
32 14 ▶ if (my $valid_email = Email::Valid->address($_[1])) {
Subroutine _is_valid_email: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if (my $valid_email = "Email::Valid"->address($_[1])) 5 9 14
33 5 return $_[1] eq $valid_email;
34 }
35  
36 9 return 0;
37 }
38  
39 12 1;
« FormValidator/Processor.pm ↑ Summary FormValidator/Validator/EmailDns.pm »