/usr/share/perl5/MooseX/Types/Common/String.pm is in libmoosex-types-common-perl 0.001004-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | package MooseX::Types::Common::String;
use strict;
use warnings;
our $VERSION = '0.001004';
use MooseX::Types -declare => [
qw(SimpleStr
NonEmptySimpleStr
LowerCaseSimpleStr
UpperCaseSimpleStr
Password
StrongPassword
NonEmptyStr
LowerCaseStr
UpperCaseStr)
];
use MooseX::Types::Moose qw/Str/;
subtype SimpleStr,
as Str,
where { (length($_) <= 255) && ($_ !~ m/\n/) },
message { "Must be a single line of no more than 255 chars" },
( $Moose::VERSION >= 2.0200
? inline_as {
$_[0]->parent()->_inline_check( $_[1] ) . ' && '
. qq{ ( (length($_[1]) <= 255) && ($_[1] !~ m/\n/) ) };
}
: ()
);
subtype NonEmptySimpleStr,
as SimpleStr,
where { length($_) > 0 },
message { "Must be a non-empty single line of no more than 255 chars" },
( $Moose::VERSION >= 2.0200
? inline_as {
$_[0]->parent()->_inline_check( $_[1] ) . ' && '
. qq{ (length($_[1]) > 0) };
}
: ()
);
subtype Password,
as NonEmptySimpleStr,
where { length($_) > 3 },
message { "Must be between 4 and 255 chars" },
( $Moose::VERSION >= 2.0200
? inline_as {
$_[0]->parent()->_inline_check( $_[1] ) . ' && '
. qq{ (length($_[1]) > 3) };
}
: ()
);
subtype StrongPassword,
as Password,
where { (length($_) > 7) && (m/[^a-zA-Z]/) },
message {"Must be between 8 and 255 chars, and contain a non-alpha char" },
( $Moose::VERSION >= 2.0200
? inline_as {
$_[0]->parent()->_inline_check( $_[1] ) . ' && '
. qq{ ( (length($_[1]) > 7) && ($_[1] =~ m/[^a-zA-Z]/) ) };
}
: ()
);
subtype NonEmptyStr,
as Str,
where { length($_) > 0 },
message { "Must not be empty" },
( $Moose::VERSION >= 2.0200
? inline_as {
$_[0]->parent()->_inline_check( $_[1] ) . ' && '
. qq{ (length($_[1]) > 0) };
}
: ()
);
subtype LowerCaseStr,
as NonEmptyStr,
where { /^[a-z]+$/xms },
message { "Must only contain lower case letters" },
( $Moose::VERSION >= 2.0200
? inline_as {
$_[0]->parent()->_inline_check( $_[1] ) . ' && '
. qq{ ( $_[1] =~ m/^[a-z]+\$/xms ) };
}
: ()
);
coerce LowerCaseStr,
from NonEmptyStr,
via { lc };
subtype UpperCaseStr,
as NonEmptyStr,
where { /^[A-Z]+$/xms },
message { "Must only contain upper case letters" },
( $Moose::VERSION >= 2.0200
? inline_as {
$_[0]->parent()->_inline_check( $_[1] ) . ' && '
. qq{ ( $_[1] =~ m/^[A-Z]+\$/xms ) };
}
: ()
);
coerce UpperCaseStr,
from NonEmptyStr,
via { uc };
subtype LowerCaseSimpleStr,
as NonEmptySimpleStr,
where { /^[a-z]+$/x },
message { "Must only contain lower case letters" },
( $Moose::VERSION >= 2.0200
? inline_as {
$_[0]->parent()->_inline_check( $_[1] ) . ' && '
. qq{ ( $_[1] =~ m/^[a-z]+\$/x ) };
}
: ()
);
coerce LowerCaseSimpleStr,
from NonEmptySimpleStr,
via { lc };
subtype UpperCaseSimpleStr,
as NonEmptySimpleStr,
where { /^[A-Z]+$/x },
message { "Must only contain upper case letters" },
( $Moose::VERSION >= 2.0200
? inline_as {
$_[0]->parent()->_inline_check( $_[1] ) . ' && '
. qq{ ( $_[1] =~ m/^[A-Z]+\$/x ) };
}
: ()
);
coerce UpperCaseSimpleStr,
from NonEmptySimpleStr,
via { uc };
1;
=head1 NAME
MooseX::Types::Common::String - Commonly used string types
=head1 SYNOPSIS
use MooseX::Types::Common::String qw/SimpleStr/;
has short_str => (is => 'rw', isa => SimpleStr);
...
#this will fail
$object->short_str("string\nwith\nbreaks");
=head1 DESCRIPTION
A set of commonly-used string type constraints that do not ship with Moose by
default.
=over
=item * SimpleStr
A Str with no new-line characters.
=item * NonEmptySimpleStr
A Str with no new-line characters and length > 0
=item * LowerCaseSimpleStr
A Str with no new-line characters, length > 0 and all lowercase characters
A coercion exists via C<lc> from NonEmptySimpleStr
=item * UpperCaseSimpleStr
A Str with no new-line characters, length > 0 and all uppercase characters
A coercion exists via C<uc> from NonEmptySimpleStr
=item * Password
=item * StrongPassword
=item * NonEmptyStr
A Str with length > 0
=item * LowerCaseStr
A Str with length > 0 and all lowercase characters.
A coercion exists via C<lc> from NonEmptyStr
=item * UpperCaseStr
A Str with length > 0 and all uppercase characters.
A coercion exists via C<uc> from NonEmptyStr
=back
=head1 SEE ALSO
=over
=item * L<MooseX::Types::Common::Numeric>
=back
=head1 AUTHORS
Please see:: L<MooseX::Types::Common>
=cut
|