blib/lib/Web/Authenticate/User/CredentialVerifier/LengthCredentialVerifier.pm untested

filter: Statementstmt 0.0% 0 / 25 Branchbran n/a Conditioncond 0.0% 0 / 3 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 36 SCAR 6.9
CC
1
Cov
0%
verify
2.0
error_msg
2.0
BEGIN
2.0
CRAP 2.0
1 package Web::Authenticate::User::CredentialVerifier::LengthCredentialVerifier;
2 $Web::Authenticate::User::CredentialVerifier::LengthCredentialVerifier::VERSION = '0.002';
3 use strict;
4 use Mouse;
5  
6 use Mouse::Util::TypeConstraints;
7
8 subtype 'Natural'
9 => as 'Int'
10 => where { $_ > 0 };
11
12 no Mouse::Util::TypeConstraints;
13  
14  
15 has name => (
16 isa => 'Str',
17 is => 'ro',
18 required => 1,
19 default => 'Length',
20 );
21  
22 with 'Web::Authenticate::User::CredentialVerifier::Role';
23  
24  
25 has min_length => (
26 isa => 'Natural',
27 is => 'ro',
28 required => 1,
29 default => 1,
30 );
31  
32  
33 has max_length => (
34 isa => 'Natural',
35 is => 'ro',
36 required => 1,
37 default => 100,
38 );
39  
40  
41 sub verify {
42 my ($self, $value) = @_;
43 my $length = length($value);
44  
45 return $length >= $self->min_length && $length <= $self->max_length;
46 }
47  
48  
49 sub error_msg {
50 my ($self) = @_;
51 return $self->name . ' must be between ' . $self->min_length . ' and ' . $self->max_length;
52 }
53  
54 1;
55  
56 __END__
57  
58 =pod
59  
60 =encoding UTF-8
61  
62 =head1 NAME
63  
64 Web::Authenticate::User::CredentialVerifier::LengthCredentialVerifier
65  
66 =head1 VERSION
67  
68 version 0.002
69  
70 =head1 METHODS
71  
72 =head2 name
73  
74 Sets the name of this L<Web::Authenticate::User::CredentialVerifier::Role>. Default is Length.
75  
76 =head2 min_length
77  
78 Sets the minimum length for a value. Default is 1.
79  
80 =head2 max_length
81  
82 Sets the maximum length for a value. Default is 100.
83  
84 =head2 verify
85  
86 Verifies that value is between L</min_length> and L</max_length>.
87  
88 my $success = $verifier->verify($value);
89  
90 =head2 error_msg
91  
92 Prints message in the form of:
93  
94 $name must be between $min_length and $max_length
95  
96 =head1 AUTHOR
97  
98 Adam Hopkins <srchulo@cpan.org>
99  
100 =head1 COPYRIGHT AND LICENSE
101  
102 This software is copyright (c) 2017 by Adam Hopkins.
103  
104 This is free software; you can redistribute it and/or modify it under
105 the same terms as the Perl 5 programming language system itself.
106  
107 =cut