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