| 1 | package HTML::FormHandler::Field::Password; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: password field | ||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | $HTML::FormHandler::Field::Password::VERSION = '0.410002'; | |||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use HTML::FormHandler::Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | extends 'HTML::FormHandler::Field::Text'; | |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 6 | has '+widget' => ( default => 'Password' ); | |||||||||||||||||||||||||||||||||||||||||
| 9 | 6 | has '+password' => ( default => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 10 | 6 | has 'ne_username' => ( isa => 'Str', is => 'rw' ); | |||||||||||||||||||||||||||||||||||||||||
| 11 | 6 | has '+type_attr' => ( default => 'password' ); | |||||||||||||||||||||||||||||||||||||||||
| 12 | 6 | has '+html5_type_attr' => ( default => 'password' ); | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 6 | our $class_messages = { | |||||||||||||||||||||||||||||||||||||||||
| 15 | 'required' => 'Please enter a password in this field', | ||||||||||||||||||||||||||||||||||||||||||
| 16 | 'password_ne_username' => 'Password must not match [_1]', | ||||||||||||||||||||||||||||||||||||||||||
| 17 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | ▶ | sub get_class_messages { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_class_messages: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 21 | my $messages = { | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 3 | %{ $self->next::method }, | |||||||||||||||||||||||||||||||||||||||||
| 23 | %$class_messages, | ||||||||||||||||||||||||||||||||||||||||||
| 24 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | ▶ | $messages->{required} = $self->required_message | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | if $self->required_message; | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 3 | return $messages; | |||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 10 | ▶ | after 'validate_field' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 10 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 10 | ▶ | if ( !$self->required && !( defined( $self->value ) && length( $self->value ) ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$self->required || defined $self->value && length $self->value
defined $self->value and length $self->value
MC/DC66%2/3
$self->required || defined $self->value && length $self->value
$self->required
defined $self->value
length $self->value
Truth table75%3/4
A || B and C
A= $self->requiredB= defined $self->valueC= length $self->value
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | $self->noupdate(1); | |||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | $self->clear_errors; | |||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 8 | ▶ | sub validate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 8 | $self->noupdate(0); | |||||||||||||||||||||||||||||||||||||||||
| 44 | 8 | ▶ | return unless $self->next::method; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 7 | my $value = $self->value; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 7 | ▶ | if ( $self->form && $self->ne_username ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->form and $self->ne_username
MC/DC50%1/2
$self->form and $self->ne_username
$self->form
$self->ne_username
Truth table66%2/3
A and B
A= $self->formB= $self->ne_username
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 4 | my $username = $self->form->get_param( $self->ne_username ); | |||||||||||||||||||||||||||||||||||||||||
| 49 | 4 | ▶ | return $self->add_error( $self->get_message('password_ne_username'), $self->ne_username ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$username and $username eq $value
MC/DC50%1/2
$username and $username eq $value
$username
$username eq $value
Truth table66%2/3
A and B
A= $usernameB= $username eq $value
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | if $username && $username eq $value; | ||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 6 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 6 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 6 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | __END__ | ||||||||||||||||||||||||||||||||||||||||||