bump version
[gitmo/MooseX-Types-Common.git] / lib / MooseX / Types / Common / String.pm
index be5d706..a9ccd6f 100644 (file)
@@ -3,11 +3,12 @@ package MooseX::Types::Common::String;
 use strict;
 use warnings;
 
-our $VERSION = '0.001004';
+our $VERSION = '0.001005';
 
 use MooseX::Types -declare => [
   qw(SimpleStr
      NonEmptySimpleStr
+     NumericCode
      LowerCaseSimpleStr
      UpperCaseSimpleStr
      Password
@@ -43,6 +44,18 @@ subtype NonEmptySimpleStr,
         : ()
     );
 
+subtype NumericCode,
+  as NonEmptySimpleStr,
+  where { $_ =~ m/^[0-9]+$/ },
+  message {
+    'Must be a non-empty single line of no more than 255 chars that consists '
+       . 'of numeric characters only'
+  };
+
+coerce NumericCode,
+  from NonEmptySimpleStr,
+  via { my $code = $_; $code =~ s/[[:punct:]]//g; return $code };
+
 subtype Password,
   as NonEmptySimpleStr,
   where { length($_) > 3 },
@@ -203,6 +216,13 @@ A coercion exists via C<uc> from NonEmptyStr
 
 =back
 
+=item * NumericCode
+
+A Str with no new-line characters that consists of only Numeric characters.
+Examples include, Social Security Numbers, PINs, 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 ).
+
 =head1 SEE ALSO
 
 =over