MuForm/Field/Password.pm

filter: Statementstmt 85.0% 17 / 20 Branchbran 50.0% 1 / 2 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 80.0% 4 / 5 Podpod 33.3% 1 / 3 totaltotal 61.5% 24 / 39 SCAR 15.1
CC
4
Cov
68%
__ANON__
8.7
build_input_type
2.0
BEGIN
1.0
CRAP 4.5
« MuForm/Field/Display.pm ↑ Summary MuForm/Field/Email.pm »
1 package Data::MuForm::Field::Password;
2 # ABSTRACT: password field
3  
4 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 extends 'Data::MuForm::Field::Text';
6  
7  
8 1 has '+password' => ( default => 1 );
9 0 ▶sub build_input_type { 'password' }
Subroutine build_input_type: not called CC=1 SCAR=6.9
Pod undocumented
10  
11 1 our $class_messages = {
12 'required' => 'Please enter a password in this field',
13 };
14  
15 sub get_class_messages {
16 1 ▶ my $self = shift;
Subroutine get_class_messages: called CC=1 SCAR=0.0
Pod undocumented
17 my $messages = {
18 1 %{ $self->next::method },
19 %$class_messages,
20 };
21 1 return $messages;
22 }
23  
24  
25 after 'field_validate' => sub {
26 6 ▶ my $self = shift;
Subroutine __ANON__: called CC=4 SCAR=21.7
27  
28 6 ▶ if ( !$self->required && !( defined( $self->value ) && length( $self->value ) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->required || defined $self->value && length $self->value) 0 6 6
Condition16%1/6
$self->required || defined $self->value && length $self->value
l!l&&r!l&&!r
600
defined $self->value and length $self->value
!ll&&!rl&&r
000
MC/DC0%0/3
$self->required || defined $self->value && length $self->value
$self->required defined $self->value length $self->value
Truth table25%1/4
A || B and C
A= $self->requiredB= defined $self->valueC= length $self->value
ABCresult
1XX1
0111
00X0
0100
29 0 $self->no_update(1);
30 0 $self->clear_errors;
31 }
32 1 };
33  
34 sub validate {
35 4 ▶ my $self = shift;
Subroutine validate: called CC=1 SCAR=0.0
Pod documented
36  
37 4 $self->no_update(0);
38 4 $self->next::method;
39  
40 }
41  
42 1 1;
43  
44 __END__
45  
46 =pod
47  
48 =encoding UTF-8
49  
50 =head1 NAME
51  
52 Data::MuForm::Field::Password - password field
53  
54 =head1 VERSION
55  
56 version 0.04
57  
58 =head1 DESCRIPTION
59  
60 The password field has a default minimum length of 6, which can be
61 easily changed:
62  
63 has_field 'password' => ( type => 'Password', minlength => 7 );
64  
65 It does not come with additional default checks, since password
66 requirements vary so widely. There are a few constraints in the
67 L<Data::MuForm::Types> modules which could be used with this
68 field: NoSpaces, WordChars, NotAllDigits.
69 These constraints can be used in the field definitions 'apply':
70  
71 use Data::MuForm::Types ('NoSpaces', 'WordChars', 'NotAllDigits' );
72 ...
73 has_field 'password' => ( type => 'Password',
74 apply => [ NoSpaces, WordChars, NotAllDigits ],
75 );
76  
77 If a password field is not required and nothing has been submitted,
78 then the field will be marked 'no_update' to keep from overwriting a
79 password in the database will a null.
80  
81 =head1 AUTHOR
82  
83 Gerda Shank
84  
85 =head1 COPYRIGHT AND LICENSE
86  
87 This software is copyright (c) 2017 by Gerda Shank.
88  
89 This is free software; you can redistribute it and/or modify it under
90 the same terms as the Perl 5 programming language system itself.
91  
92 =cut
« MuForm/Field/Display.pm ↑ Summary MuForm/Field/Email.pm »