FormHandler/Field/Email.pm

filter: Statementstmt 83.3% 25 / 30 Branchbran 75.0% 3 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 71.4% 5 / 7 Podpod 0.0% 0 / 1 totaltotal 75.5% 34 / 45 CC 4 SCAR 7.1
CC
4
Cov
81%
__ANON__
3.1
get_class_messages
2.0
__ANON__
2.0
CRAP 2.0
« FormHandler/Field/Display.pm ↑ Summary FormHandler/Widget/Field/Reset.pm »
1 package HTML::FormHandler::Field::Email;
2 # ABSTRACT: validates email using Email::Valid
3 4 $HTML::FormHandler::Field::Email::VERSION = '0.410002';
4 4 ▶use HTML::FormHandler::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 extends 'HTML::FormHandler::Field::Text';
6 4 ▶use Email::Valid;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 our $class_messages = {
9 'email_format' => 'Email should be of the format [_1]',
10 };
11 4 has '+html5_type_attr' => ( default => 'email' );
12  
13 4 has 'email_valid_params' => (
14 is => 'rw',
15 isa => 'HashRef',
16 );
17  
18 4 has 'preserve_case' => (
19 is => 'rw',
20 isa => 'Bool',
21 );
22  
23 0 ▶sub get_class_messages {
Subroutine get_class_messages: not called CC=1 SCAR=6.9
Pod undocumented
24 0 my $self = shift;
25 return {
26 0 %{ $self->next::method },
27 %$class_messages,
28 }
29 }
30  
31 apply(
32 [
33 {
34 5 ▶ transform => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
35 5 my ( $value, $field ) = @_;
36 5 ▶ return $value
Branch: 1 branch
BranchTrueFalseTotal
if $field->preserve_case 2 3 5
37 if $field->preserve_case;
38 3 return lc( $value );
39 }
40 },
41 {
42 5 ▶ check => sub {
Subroutine __ANON__: called CC=3 SCAR=11.4
43 5 my ( $value, $field ) = @_;
44 my $checked = Email::Valid->address(
45 5 ▶ %{ $field->email_valid_params || {} },
Condition50%1/2
$field->email_valid_params || {}
l!l
05
MC/DC0%0/1
$field->email_valid_params || {}
$field->email_valid_params
Truth table50%1/2
A
A= $field->email_valid_params
Aresult
11
00
46 -address => $value,
47 );
48 5 ▶ $field->value($checked)
Branch: 1 branch
BranchTrueFalseTotal
if $checked 5 0 5
49 if $checked;
50 },
51 0 ▶ message => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
52 0 my ( $value, $field ) = @_;
53 0 return [$field->get_message('email_format'), 'someuser@example.com'];
54 },
55 }
56 4 ]
57 );
58  
59  
60 4 __PACKAGE__->meta->make_immutable;
61 4 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
62 4 1;
63  
64 __END__
« FormHandler/Field/Display.pm ↑ Summary FormHandler/Widget/Field/Reset.pm »