Skip to content

Commit

Permalink
Updated fix to take into account other options passed to validation c…
Browse files Browse the repository at this point in the history
…onstraint
  • Loading branch information
bravik committed Mar 4, 2022
1 parent 05fab28 commit 8c5c685
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Generator/TypeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,20 @@ protected function buildConstraints(array $constraints = [], bool $inClosure = t
// Nested instance
$instance->addArgument($this->buildConstraints($args, false));
} elseif (isset($args['constraints'][0]) && is_array($args['constraints'][0])) {
// Nested instance with explicit "constraints" key
$instance->addArgument($this->buildConstraints($args['constraints'], false));
// Nested instance with "constraints" key (full syntax)
$options = [
'constraints' => $this->buildConstraints($args['constraints'], false),
];

// Check for additional options
foreach ($args as $key => $option) {
if ('constraints' === $key) {
continue;
}
$options[$key] = $option;
}

$instance->addArgument($options);
} else {
// Numeric or Assoc array?
$instance->addArgument(isset($args[0]) ? $args : Collection::assoc($args));
Expand Down

0 comments on commit 8c5c685

Please sign in to comment.