1 package MooseX::Types::Common;
6 our $VERSION = '0.001000';
8 use MooseX::Types -declare => [
9 qw(SimpleStr NonEmptySimpleStr Password StrongPassword NonEmptyStr
10 PositiveNum PositiveInt NegativeNum NegativeInt SingleDigit)
13 use MooseX::Types::Moose qw/Str Num Int Object/;
17 where { (length($_) <= 255) && ($_ !~ m/\n/) },
18 message { "Must be a single line of no more than 255 chars" };
20 subtype NonEmptySimpleStr,
22 where { length($_) > 0 },
23 message { "Must be a non-empty single line of no more than 255 chars" };
25 # XXX duplicating constraint msges since moose only uses last message
28 where { length($_) > 3 },
29 message { "Must be between 4 and 255 chars" };
31 subtype StrongPassword,
33 where { (length($_) > 7) && (m/[^a-zA-Z]/) },
34 message {"Must be between 8 and 255 chars, and contain a non-alpha char" };
38 where { length($_) > 0 },
39 message { "Must not be empty" };
44 message { "Must be a positive number" };
49 message { "Must be a positive integer" };
54 message { "Must be a negative number" };
59 message { "Must be a negative integer" };
64 message { "Must be a single digit" };
74 use MooseX::Types::Common qw/SimpleStr/;
75 has short_str => (is => 'rw', isa => SimpleStr);
79 $object->short_str("string\nwith\nbreaks");
83 A set of commonly-used type constraints that do not ship with Moose by default.
89 A Str with no new-line characters.
91 =item * NonEmptySimpleStr
93 Does what it says on the tin.
97 =item * StrongPassword
117 =item * L<MooseX::Types>
119 =item * L<Moose::Util::TypeConstraints>
125 This distribution was extracted from the L<Reaction> code base by Guillermo
128 The original authors of this library are:
132 =item * Matt S. Trout
134 =item * K. J. Cheetham
136 =item * Guillermo Roditi
142 This library is free software, you can redistribute it and/or modify
143 it under the same terms as Perl itself.