1 package MooseX::Types::Common::String;
6 our $VERSION = '0.001001';
8 use MooseX::Types -declare => [
9 qw(SimpleStr NonEmptySimpleStr Password StrongPassword NonEmptyStr)
12 use MooseX::Types::Moose qw/Str/;
16 where { (length($_) <= 255) && ($_ !~ m/\n/) },
17 message { "Must be a single line of no more than 255 chars" };
19 subtype NonEmptySimpleStr,
21 where { length($_) > 0 },
22 message { "Must be a non-empty single line of no more than 255 chars" };
24 # XXX duplicating constraint msges since moose only uses last message
27 where { length($_) > 3 },
28 message { "Must be between 4 and 255 chars" };
30 subtype StrongPassword,
32 where { (length($_) > 7) && (m/[^a-zA-Z]/) },
33 message {"Must be between 8 and 255 chars, and contain a non-alpha char" };
37 where { length($_) > 0 },
38 message { "Must not be empty" };
45 MooseX::Types::Common::String - Commonly used string types
49 use MooseX::Types::Common::String qw/SimpleStr/;
50 has short_str => (is => 'rw', isa => SimpleStr);
54 $object->short_str("string\nwith\nbreaks");
58 A set of commonly-used string type constraints that do not ship with Moose by
65 A Str with no new-line characters.
67 =item * NonEmptySimpleStr
69 Does what it says on the tin.
73 =item * StrongPassword
83 =item * L<MooseX::Types::Common::Numeric>
89 Please see:: L<MooseX::Types::Common>