File Coverage

blib/lib/MouseX/Types/Common/String.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package MouseX::Types::Common::String;
2              
3 2     2   94699 use strict;
  2         6  
  2         64  
4 2     2   10 use warnings;
  2         4  
  2         108  
5              
6             our $VERSION = '0.001000';
7              
8 2         573 use MouseX::Types -declare => [
9             qw(SimpleStr NonEmptySimpleStr Password StrongPassword NonEmptyStr)
10 2     2   1672 ];
  2         56756  
11              
12 2     2   4682 use MouseX::Types::Mouse qw/Str/;
  2         1496  
  2         14  
13              
14             subtype SimpleStr,
15             as Str,
16             where { (length($_) <= 255) && ($_ !~ m/\n/) },
17             message { "Must be a single line of no more than 255 chars" };
18              
19             subtype NonEmptySimpleStr,
20             as SimpleStr,
21             where { length($_) > 0 },
22             message { "Must be a non-empty single line of no more than 255 chars" };
23              
24             # XXX duplicating constraint msges since moose only uses last message
25             subtype Password,
26             as NonEmptySimpleStr,
27             where { length($_) > 3 },
28             message { "Must be between 4 and 255 chars" };
29              
30             subtype StrongPassword,
31             as Password,
32             where { (length($_) > 7) && (m/[^a-zA-Z]/) },
33             message {"Must be between 8 and 255 chars, and contain a non-alpha char" };
34              
35             subtype NonEmptyStr,
36             as Str,
37             where { length($_) > 0 },
38             message { "Must not be empty" };
39              
40              
41             1;
42             __END__