From dc0eccd940f38352d06abf3a707b56eecfdd97f6 Mon Sep 17 00:00:00 2001 From: Kay Wei Date: Wed, 15 Nov 2023 17:10:49 +0800 Subject: [PATCH] Fix wrong parameter passing and add these rules to dependent rules --- .../Validation/Concerns/ValidatesAttributes.php | 8 ++++---- src/Illuminate/Validation/Validator.php | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php index 4b11c28f5e30..df5bb1fc2005 100644 --- a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php @@ -1743,7 +1743,7 @@ public function validatePresentIf($attribute, $value, $parameters) [$values, $other] = $this->parseDependentRuleParameters($parameters); if (in_array($other, $values, is_bool($other) || is_null($other))) { - return $this->validatePresent($attribute, $value, $parameters); + return $this->validatePresent($attribute, $value); } return true; @@ -1764,7 +1764,7 @@ public function validatePresentUnless($attribute, $value, $parameters) [$values, $other] = $this->parseDependentRuleParameters($parameters); if (! in_array($other, $values, is_bool($other) || is_null($other))) { - return $this->validatePresent($attribute, $value, $parameters); + return $this->validatePresent($attribute, $value); } return true; @@ -1783,7 +1783,7 @@ public function validatePresentWith($attribute, $value, $parameters) $this->requireParameterCount(1, $parameters, 'present_with'); if (Arr::hasAny($this->data, $parameters)) { - return $this->validatePresent($attribute, $value, $parameters); + return $this->validatePresent($attribute, $value); } return true; @@ -1802,7 +1802,7 @@ public function validatePresentWithAll($attribute, $value, $parameters) $this->requireParameterCount(1, $parameters, 'present_with_all'); if (Arr::has($this->data, $parameters)) { - return $this->validatePresent($attribute, $value, $parameters); + return $this->validatePresent($attribute, $value); } return true; diff --git a/src/Illuminate/Validation/Validator.php b/src/Illuminate/Validation/Validator.php index 0629287d6e8a..ef74c14af8f4 100755 --- a/src/Illuminate/Validation/Validator.php +++ b/src/Illuminate/Validation/Validator.php @@ -256,6 +256,10 @@ class Validator implements ValidatorContract 'RequiredWithAll', 'RequiredWithout', 'RequiredWithoutAll', + 'PresentIf', + 'PresentUnless', + 'PresentWith', + 'PresentWithAll', 'Prohibited', 'ProhibitedIf', 'ProhibitedUnless',