package MooseX::Types::Common::String;
+# ABSTRACT: Commonly used string types
use strict;
use warnings;
-our $VERSION = '0.001005';
-
use MooseX::Types -declare => [
qw(SimpleStr
NonEmptySimpleStr
subtype LowerCaseStr,
as NonEmptyStr,
- where { /^[a-z]+$/xms },
- message { "Must only contain lower case letters" },
+ where { !/[A-Z]/ms },
+ message { "Must not contain upper case letters" },
( $Moose::VERSION >= 2.0200
? inline_as {
$_[0]->parent()->_inline_check( $_[1] ) . ' && '
- . qq{ ( $_[1] =~ m/^[a-z]+\$/xms ) };
+ . qq{ ( $_[1] !~ /[A-Z]/ms ) };
}
: ()
);
subtype UpperCaseStr,
as NonEmptyStr,
- where { /^[A-Z]+$/xms },
- message { "Must only contain upper case letters" },
+ where { !/[a-z]/ms },
+ message { "Must not contain lower case letters" },
( $Moose::VERSION >= 2.0200
? inline_as {
$_[0]->parent()->_inline_check( $_[1] ) . ' && '
- . qq{ ( $_[1] =~ m/^[A-Z]+\$/xms ) };
+ . qq{ ( $_[1] !~ m/[a-z]/ms ) };
}
: ()
);
subtype LowerCaseSimpleStr,
as NonEmptySimpleStr,
- where { /^[a-z]+$/x },
- message { "Must only contain lower case letters" },
+ where { !/[A-Z]/ },
+ message { "Must not contain upper case letters" },
( $Moose::VERSION >= 2.0200
? inline_as {
$_[0]->parent()->_inline_check( $_[1] ) . ' && '
- . qq{ ( $_[1] =~ m/^[a-z]+\$/x ) };
+ . qq{ ( $_[1] !~ m/[A-Z]/ ) };
}
: ()
);
-
+
coerce LowerCaseSimpleStr,
from NonEmptySimpleStr,
via { lc };
subtype UpperCaseSimpleStr,
as NonEmptySimpleStr,
- where { /^[A-Z]+$/x },
- message { "Must only contain upper case letters" },
+ where { !/[a-z]/ },
+ message { "Must not contain lower case letters" },
( $Moose::VERSION >= 2.0200
? inline_as {
$_[0]->parent()->_inline_check( $_[1] ) . ' && '
- . qq{ ( $_[1] =~ m/^[A-Z]+\$/x ) };
+ . qq{ ( $_[1] !~ m/[a-z]/ ) };
}
: ()
);
via { uc };
1;
+__END__
-=head1 NAME
-
-MooseX::Types::Common::String - Commonly used string types
+=pod
=head1 SYNOPSIS
=over
-=item * SimpleStr
+=item * C<SimpleStr>
-A Str with no new-line characters.
+A C<Str> with no new-line characters.
-=item * NonEmptySimpleStr
+=item * C<NonEmptySimpleStr>
-A Str with no new-line characters and length > 0
+A C<Str> with no new-line characters and length > 0
-=item * LowerCaseSimpleStr
+=item * C<LowerCaseSimpleStr>
-A Str with no new-line characters, length > 0 and all lowercase characters
-A coercion exists via C<lc> from NonEmptySimpleStr
+A C<Str> with no new-line characters, length > 0 and no uppercase characters
+A coercion exists via C<lc> from C<NonEmptySimpleStr>
-=item * UpperCaseSimpleStr
+=item * C<UpperCaseSimpleStr>
-A Str with no new-line characters, length > 0 and all uppercase characters
-A coercion exists via C<uc> from NonEmptySimpleStr
+A C<Str> with no new-line characters, length > 0 and no lowercase characters
+A coercion exists via C<uc> from C<NonEmptySimpleStr>
-=item * Password
+=item * C<Password>
-=item * StrongPassword
+=item * C<StrongPassword>
-=item * NonEmptyStr
+=item * C<NonEmptyStr>
-A Str with length > 0
+A C<Str> with length > 0
-=item * LowerCaseStr
+=item * C<LowerCaseStr>
-A Str with length > 0 and all lowercase characters.
-A coercion exists via C<lc> from NonEmptyStr
+A C<Str> with length > 0 and no uppercase characters.
+A coercion exists via C<lc> from C<NonEmptyStr>
-=item * UpperCaseStr
+=item * C<UpperCaseStr>
-A Str with length > 0 and all uppercase characters.
-A coercion exists via C<uc> from NonEmptyStr
+A C<Str> with length > 0 and no lowercase characters.
+A coercion exists via C<uc> from C<NonEmptyStr>
-=item * NumericCode
+=item * C<NumericCode>
-A Str with no new-line characters that consists of only Numeric characters.
-Examples include, Social Security Numbers, PINs, Postal Codes, HTTP Status
+A C<Str> with no new-line characters that consists of only Numeric characters.
+Examples include, Social Security Numbers, Personal Identification Numbers, Postal Codes, HTTP Status
Codes, etc. Supports attempting to coerce from a string that has punctuation
in it ( e.g credit card number 4111-1111-1111-1111 ).
=back
-=head1 AUTHORS
-
-Please see:: L<MooseX::Types::Common>
-
=cut