| 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
Condition16%1/6
$self->required || defined $self->value && length $self->value
defined $self->value and length $self->value
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||||||||||||||||||