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");
}
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)) {
return $constraint;
}
+sub normalize_type_constraint_name {
+ my $type_constraint_name = shift @_;
+ $type_constraint_name =~s/\s//g;
+ return $type_constraint_name;
+}
+
## --------------------------------------------------------
## exported functions ...
## --------------------------------------------------------
=over 4
+=item B<normalize_type_constraint_name ($type_constraint_name)>
+
+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<create_type_constraint_union ($pipe_seperated_types | @type_constraint_names)>
Given string with C<$pipe_seperated_types> or a list of C<@type_constraint_names>,