| 1 | package Data::Validation::Constraints::Password; | ||||||||||||
| 2 | |||||||||||||
| 3 | 1 | ▶ | use namespace::autoclean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | |||||||||||||
| 5 | 1 | ▶ | use Data::Validation::Constants qw( EXCEPTION_CLASS FALSE TRUE ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 1 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | 1 | extends q(Data::Validation::Constraints); | |||||||||||
| 9 | |||||||||||||
| 10 | 1 | EXCEPTION_CLASS->add_exception( 'ValidPassword', { | |||||||||||
| 11 | parents => [ 'InvalidParameter' ], | ||||||||||||
| 12 | error => 'Parameter [_1] is not a valid password', | ||||||||||||
| 13 | explain => 'Must be longer than {min_length} characters long, contain ' | ||||||||||||
| 14 | . 'non alpha characters and must not be wholely numeric' } ); | ||||||||||||
| 15 | |||||||||||||
| 16 | 10 | ▶ | sub validate { | ||||||||||
|
Subroutine
validate: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||
| 17 | 10 | ▶ | my ($self, $val) = @_; my $min_length = $self->min_length || 6; | ||||||||||
|
Condition100%2/2
$self->min_length || 6
MC/DC100%1/1
$self->min_length || 6
$self->min_length
Truth table100%2/2
A
A= $self->min_length
| |||||||||||||
| 18 | |||||||||||||
| 19 | 10 | ▶ | length $val < $min_length and return FALSE; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 20 | 8 | ▶ | $val =~ m{ \A \d+ \z }mx and return FALSE; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 21 | 7 | $val =~ tr{A-Z}{a-z}; $val =~ tr{a-z}{}d; | |||||||||||
| 22 | 7 | ▶ | return length $val > 0 ? TRUE : FALSE; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 23 | } | ||||||||||||
| 24 | |||||||||||||
| 25 | 1 | 1; | |||||||||||
| 26 | |||||||||||||
| 27 | # Local Variables: | ||||||||||||
| 28 | # mode: perl | ||||||||||||
| 29 | # tab-width: 3 | ||||||||||||
| 30 | # End: | ||||||||||||