Skip to content

Commit

Permalink
optimize exists validation for empty array input (#48684)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtawil committed Oct 10, 2023
1 parent 219a497 commit 3b40b36
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Illuminate/Validation/Concerns/ValidatesAttributes.php
Expand Up @@ -864,6 +864,10 @@ public function validateExists($attribute, $value, $parameters)

$expected = is_array($value) ? count(array_unique($value)) : 1;

if ($expected === 0) {
return true;
}

return $this->getExistCount(
$connection, $table, $column, $value, $parameters
) >= $expected;
Expand Down

0 comments on commit 3b40b36

Please sign in to comment.