X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FUtil%2FTypeConstraints.pm;h=08888841fe64e7da8e702a528de16bd9246d843f;hb=eb4c4e821e3636e607b09919b1403d52ddbee092;hp=05df46886cbf0b2ed6dab1a688321ac06d6d8bf5;hpb=6217e87a7755f70a92f848f7c609cfd8ef4d2873;p=gitmo%2FMoose.git diff --git a/lib/Moose/Util/TypeConstraints.pm b/lib/Moose/Util/TypeConstraints.pm index 05df468..0888884 100644 --- a/lib/Moose/Util/TypeConstraints.pm +++ b/lib/Moose/Util/TypeConstraints.pm @@ -101,7 +101,7 @@ sub create_type_constraint_union (@) { else { @type_constraint_names = @_; } - + (scalar @type_constraint_names >= 2) || Moose->throw_error("You must pass in at least 2 type names to make a union"); @@ -223,7 +223,7 @@ sub find_or_create_does_type_constraint ($) { } sub find_or_parse_type_constraint ($) { - my $type_constraint_name = shift; + my $type_constraint_name = normalize_type_constraint_name(shift); my $constraint; if ($constraint = find_type_constraint($type_constraint_name)) { @@ -240,6 +240,12 @@ sub find_or_parse_type_constraint ($) { return $constraint; } +sub normalize_type_constraint_name { + my $type_constraint_name = shift @_; + $type_constraint_name =~s/\s//g; + return $type_constraint_name; +} + ## -------------------------------------------------------- ## exported functions ... ## -------------------------------------------------------- @@ -926,6 +932,11 @@ This is just sugar for the type coercion construction syntax. =over 4 +=item B + +Given a string that is expected to match a type constraint, will normalize the +string so that extra whitespace and newlines are removed. + =item B Given string with C<$pipe_seperated_types> or a list of C<@type_constraint_names>,