Skip to content

Commit 6eb2675

Browse files
committed
fix: requiredIf not work on field validation. fix #22
1 parent 4c1ba48 commit 6eb2675

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Traits/ScopedValidatorsTrait.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ public function requiredIf(string $field, $fieldVal, string $anotherField, $valu
199199
if (isset($this->data[$anotherField])) {
200200
$anotherVal = $this->data[$anotherField];
201201

202-
if (in_array($anotherVal, (array)$values, true)) {
202+
// if (in_array($anotherVal, (array)$values, true)) {
203+
if (Helper::inArray($anotherVal, (array)$values)) {
203204
return $this->required($field, $fieldVal);
204205
}
205206
}
@@ -223,7 +224,8 @@ public function requiredUnless(string $field, $fieldVal, string $anotherField, $
223224
if (isset($this->data[$anotherField])) {
224225
$anotherVal = $this->data[$anotherField];
225226

226-
if (in_array($anotherVal, (array)$values, true)) {
227+
// if (in_array($anotherVal, (array)$values, true)) {
228+
if (Helper::inArray($anotherVal, (array)$values)) {
227229
return null;
228230
}
229231
}

0 commit comments

Comments
 (0)