| 1 | package HTML::FormHandler::Field::PasswordConf; | ||||||||||||
| 2 | # ABSTRACT: password confirmation | ||||||||||||
| 3 | 3 | $HTML::FormHandler::Field::PasswordConf::VERSION = '0.410002'; | |||||||||||
| 4 | 3 | ▶ | use HTML::FormHandler::Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 3 | extends 'HTML::FormHandler::Field::Text'; | |||||||||||
| 6 | |||||||||||||
| 7 | |||||||||||||
| 8 | 3 | has '+widget' => ( default => 'Password' ); | |||||||||||
| 9 | 3 | has '+password' => ( default => 1 ); | |||||||||||
| 10 | 3 | has '+required' => ( default => 1 ); | |||||||||||
| 11 | 3 | has 'password_field' => ( isa => 'Str', is => 'rw', default => 'password' ); | |||||||||||
| 12 | 3 | has 'pass_conf_message' => ( isa => 'Str', is => 'rw' ); | |||||||||||
| 13 | |||||||||||||
| 14 | 3 | our $class_messages = { | |||||||||||
| 15 | required => 'Please enter a password confirmation', | ||||||||||||
| 16 | pass_conf_not_matched => 'The password confirmation does not match the password', | ||||||||||||
| 17 | }; | ||||||||||||
| 18 | |||||||||||||
| 19 | 2 | ▶ | sub get_class_messages { | ||||||||||
|
Subroutine
get_class_messages: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||
| 20 | 2 | my $self = shift; | |||||||||||
| 21 | my $messages = { | ||||||||||||
| 22 | 2 | %{ $self->next::method }, | |||||||||||
| 23 | %$class_messages, | ||||||||||||
| 24 | }; | ||||||||||||
| 25 | 2 | ▶ | $messages->{pass_conf_not_matched} = $self->pass_conf_message | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 26 | if $self->pass_conf_message; | ||||||||||||
| 27 | 2 | return $messages; | |||||||||||
| 28 | } | ||||||||||||
| 29 | |||||||||||||
| 30 | |||||||||||||
| 31 | 3 | ▶ | sub validate { | ||||||||||
|
Subroutine
validate: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||
| 32 | 3 | my $self = shift; | |||||||||||
| 33 | |||||||||||||
| 34 | 3 | my $value = $self->value; | |||||||||||
| 35 | 3 | ▶ | my $password = $self->form->field( $self->password_field )->value || ''; | ||||||||||
|
Condition100%2/2
$self->form->field($self->password_field)->value || ''
MC/DC100%1/1
$self->form->field($self->password_field)->value || ''
$self->form->field($self->password_field)->value
Truth table100%2/2
A
A= $self->form->field($self->password_field)->value
| |||||||||||||
| 36 | 3 | ▶ | if ( $password ne $self->value ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 37 | 2 | $self->add_error( $self->get_message('pass_conf_not_matched') ); | |||||||||||
| 38 | 2 | return; | |||||||||||
| 39 | } | ||||||||||||
| 40 | 1 | return 1; | |||||||||||
| 41 | } | ||||||||||||
| 42 | |||||||||||||
| 43 | 3 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 44 | 3 | ▶ | use namespace::autoclean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 45 | 3 | 1; | |||||||||||
| 46 | |||||||||||||
| 47 | __END__ | ||||||||||||