line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Validation::Constraints::Password; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
537
|
use namespace::autoclean; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
71
|
use Data::Validation::Constants qw( EXCEPTION_CLASS FALSE TRUE ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
6
|
1
|
|
|
1
|
|
264
|
use Moo; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
extends q(Data::Validation::Constraints); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub validate { |
17
|
10
|
|
100
|
10
|
1
|
17
|
my ($self, $val) = @_; my $min_length = $self->min_length || 6; |
|
10
|
|
|
|
|
40
|
|
18
|
|
|
|
|
|
|
|
19
|
10
|
100
|
|
|
|
23
|
length $val < $min_length and return FALSE; |
20
|
8
|
100
|
|
|
|
27
|
$val =~ m{ \A \d+ \z }mx and return FALSE; |
21
|
7
|
|
|
|
|
11
|
$val =~ tr{A-Z}{a-z}; $val =~ tr{a-z}{}d; |
|
7
|
|
|
|
|
9
|
|
22
|
7
|
100
|
|
|
|
24
|
return length $val > 0 ? TRUE : FALSE; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
1; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Local Variables: |
28
|
|
|
|
|
|
|
# mode: perl |
29
|
|
|
|
|
|
|
# tab-width: 3 |
30
|
|
|
|
|
|
|
# End: |