Do some hackish validation of type names in MUTC, though unfortunately
[gitmo/Moose.git] / lib / Moose / Util / TypeConstraints.pm
index eb253d9..5b1db5d 100644 (file)
@@ -381,6 +381,10 @@ sub _create_type_constraint ($$$;$$) {
                 . " and cannot be created again in "
                 . $pkg_defined_in )
             if defined $type;
+
+        $name =~ /^[\w:\.]+$/
+            or die qq{$name contains invalid characters for a type name.}
+            . qq{Names can contain alphanumeric character, ":", and "."\n};
     }
 
     my %opts = (
@@ -439,7 +443,7 @@ sub _install_type_coercions ($$) {
 
     use re "eval";
 
-    my $valid_chars = qr{[\w:]};
+    my $valid_chars = qr{[\w:\.]};
     my $type_atom   = qr{ $valid_chars+ };
 
     my $any;
@@ -788,6 +792,9 @@ but it is a saner restriction than most others.
 
 =head2 Type Constraint Naming
 
+Type name declared via this module can only contain alphanumeric
+characters, colons (:), and periods (.).
+
 Since the types created by this module are global, it is suggested
 that you namespace your types just as you would namespace your
 modules. So instead of creating a I<Color> type for your B<My::Graphics>