rollback some stuff to reset my brain a bit
[gitmo/MooseX-Types-Structured.git] / lib / MooseX / Meta / TypeConstraint / Structured / Positional.pm
index f51a9d6..d29ed46 100644 (file)
@@ -94,8 +94,8 @@ sub constraint {
     return sub {
         my @args = $self->_normalize_args(shift);
         my @signature = @{$self->signature};
-        my @optional_signature = @{$self->optional_signature}
-         if $self->has_optional_signature;
+               my @optional_signature = @{$self->optional_signature}
+               if $self->has_optional_signature; 
         
         ## First make sure all the required type constraints match        
         while( my $type_constraint = shift @signature) {
@@ -106,10 +106,13 @@ sub constraint {
         
         ## Now test the option type constraints.
         while( my $arg = shift @args) {
-            my $optional_type_constraint = shift @optional_signature;
-            if(my $error = $optional_type_constraint->validate($arg)) {
-                confess $error;
-            }              
+            if(my $optional_type_constraint = shift @optional_signature) {
+                if(my $error = $optional_type_constraint->validate($arg)) {
+                    confess $error;
+                }                              
+            } else {
+                confess "Too Many arguments for the available type constraints";
+            }
         }
         
         ## If we got this far we passed!