lib/Reaction/Types/Core.pm

filter: Statementstmt 50.0% 17 / 34 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 10.5% 2 / 19 Podpod n/a totaltotal 33.3% 19 / 57 CC 3 SCAR 8.3
CC
3
Cov
45%
__ANON__
6.0
__ANON__
6.0
__ANON__
2.0
CRAP 2.3
« lib/Reaction/UI/ViewPort/Action/Role/Close.pm ↑ Summary lib/Reaction/InterfaceModel/Collection/DBIC/Role/Base.pm »
1 package Reaction::Types::Core;
2  
3 use MooseX::Types
4 9 ▶ -declare => [qw/SimpleStr NonEmptySimpleStr Password StrongPassword
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 NonEmptyStr PositiveNum PositiveInt SingleDigit URI/];
6  
7 9 ▶use MooseX::Types::Moose qw/Str Num Int Object/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 subtype SimpleStr,
10 as Str,
11 0 ▶ where { (length($_) <= 255) && ($_ !~ m/\n/) },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
length $_ <= 255 and not $_ =~ /\n/ 0 0 0
12 0 ▶ message { "Must be a single line of no more than 255 chars" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
13  
14 subtype NonEmptySimpleStr,
15 as SimpleStr,
16 0 ▶ where { length($_) > 0 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
17 0 ▶ message { "Must be a non-empty single line of no more than 255 chars" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
18  
19 # XXX duplicating constraint msges since moose only uses last message
20  
21 subtype Password,
22 as NonEmptySimpleStr,
23 0 ▶ where { length($_) > 3 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
24 0 ▶ message { "Must be between 4 and 255 chars" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
25  
26 subtype StrongPassword,
27 as Password,
28 0 ▶ where { (length($_) > 7) && (m/[^a-zA-Z]/) },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
length $_ > 7 and /[^a-zA-Z]/ 0 0 0
29 0 ▶ message {
Subroutine __ANON__: not called CC=1 SCAR=1.2
30 0 "Must be between 8 and 255 chars, and contain a non-alpha char" };
31  
32 subtype NonEmptyStr,
33 as Str,
34 0 ▶ where { length($_) > 0 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
35 0 ▶ message { "Must not be empty" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
36  
37 subtype PositiveNum,
38 as Num,
39 0 ▶ where { $_ >= 0 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
40 0 ▶ message { "Must be a positive number" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
41  
42 subtype PositiveInt,
43 as Int,
44 0 ▶ where { $_ >= 0 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
45 0 ▶ message { "Must be a positive integer" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
46  
47 subtype SingleDigit,
48 as PositiveInt,
49 0 ▶ where { $_ <= 9 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
50 0 ▶ message { "Must be a single digit" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
51  
52 #message will require moose 0.39
53 9 class_type 'URI';
54 #class_type 'URI', message { 'Must be an URI object'};
55 0 ▶coerce 'URI', from Str, via { URI->new($_) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
56  
57 9 1;
58  
59 =head1 NAME
60  
61 Reaction::Types::Core
62  
63 =head1 SYNOPSIS
64  
65 =head1 DESCRIPTION
66  
67 Reaction uses the L<Moose> attributes as a base and adds a few of it's own.
68  
69 =over
70  
71 =item * SimpleStr
72  
73 A Str with no new-line characters.
74  
75 =item * NonEmptySimpleStr
76  
77 Does what it says on the tin.
78  
79 =item * Password
80  
81 =item * StrongPassword
82  
83 =item * NonEmptyStr
84  
85 =item * PositiveNum
86  
87 =item * PositiveInt
88  
89 =item * SingleDigit
90  
91 =back
92  
93 =head1 SEE ALSO
94  
95 =over
96  
97 =item * L<Moose::Util::TypeConstraints>
98  
99 =item * L<Reaction::Types::DBIC>
100  
101 =item * L<Reaction::Types::DateTime>
102  
103 =item * L<Reaction::Types::Email>
104  
105 =item * L<Reaction::Types::File>
106  
107 =back
108  
109 =head1 AUTHORS
110  
111 See L<Reaction::Class> for authors.
112  
113 =head1 LICENSE
114  
115 See L<Reaction::Class> for the license.
116  
117 =cut
« lib/Reaction/UI/ViewPort/Action/Role/Close.pm ↑ Summary lib/Reaction/InterfaceModel/Collection/DBIC/Role/Base.pm »