squelch a warning in Reaction::Class, port from BindLex to Component::ACCEPT_CONTEXT
[catagits/Reaction.git] / lib / Reaction / Types / Core.pm
CommitLineData
7adfd53f 1package Reaction::Types::Core;
2
3use Moose::Util::TypeConstraints;
4
5subtype 'SimpleStr'
6 => as 'Str'
7 => where { (length($_) <= 255) && ($_ !~ m/\n/) }
8 => message { "Must be a single line of no more than 255 chars" };
9
10subtype 'NonEmptySimpleStr'
11 => as 'SimpleStr'
12 => where { length($_) > 0 }
13 => message { "Must be a non-empty single line of no more than 255 chars" };
14
15# XXX duplicating constraint msges since moose only uses last message
16
17subtype 'Password'
18 => as 'NonEmptySimpleStr'
19 => where { length($_) > 3 }
20 => message { "Must be between 4 and 255 chars" };
21
22subtype 'StrongPassword'
23 => as 'Password'
24 => where { (length($_) > 7) && (m/[^a-zA-Z]/) }
25 => message { "Must be between 8 and 255 chars, and contain a non-alpha char" };
26
27subtype 'NonEmptyStr'
28 => as 'Str'
29 => where { length($_) > 0 }
30 => message { "Must not be empty" };
31
32subtype 'PositiveNum'
33 => as 'Num'
34 => where { $_ >= 0 }
35 => message { "Must be a positive number" };
36
37subtype 'PositiveInt'
38 => as 'Int'
39 => where { $_ >= 0 }
40 => message { "Must be a positive integer" };
41
42subtype 'SingleDigit'
43 => as 'PositiveInt'
44 => where { $_ <= 9 }
45 => message { "Must be a single digit" };
46
471;
48
49=head1 NAME
50
51Reaction::Types::Core
52
53=head1 SYNOPSIS
54
55=head1 DESCRIPTION
56
57Reaction uses the L<Moose> attributes as a base and adds a few of it's own.
58
59=over
60
61=item * SimpleStr
62
63A Str with no new-line characters.
64
65=item * NonEmptySimpleStr
66
67Does what it says on the tin.
68
69=item * Password
70
71=item * StrongPassword
72
73=item * NonEmptyStr
74
75=item * PositiveNum
76
77=item * PositiveInt
78
79=item * SingleDigit
80
81=back
82
83=head1 SEE ALSO
84
85=over
86
87=item * L<Moose::Util::TypeConstraints>
88
89=item * L<Reaction::Types::DBIC>
90
91=item * L<Reaction::Types::DateTime>
92
93=item * L<Reaction::Types::Email>
94
95=item * L<Reaction::Types::File>
96
97=back
98
99=head1 AUTHORS
100
101See L<Reaction::Class> for authors.
102
103=head1 LICENSE
104
105See L<Reaction::Class> for the license.
106
107=cut