Skip to content

Commit

Permalink
fix: patch up array check
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Nov 12, 2023
1 parent b724596 commit f678fa9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static function test(string $rule, $value, $param = null, $field = null):
$rule = $ruleData[0];

if (in_array($rule, static::$specialRules)) {
$params = explode('|', str_replace(['(', ')'], '', $ruleData[1]));
$params = array_filter(explode('|', str_replace(['(', ')'], '', $ruleData[1])));

if ($rule === 'array') {
if (!is_array($value)) {
Expand All @@ -124,10 +124,12 @@ public static function test(string $rule, $value, $param = null, $field = null):

$isValid = true;

foreach ($params as $paramValue) {
foreach ($value as $valueArrayItem) {
if (!static::test($paramValue, $valueArrayItem)) {
$isValid = false;
if (count($params) > 0) {
foreach ($params as $paramValue) {
foreach ($value as $valueArrayItem) {
if (!static::test($paramValue, $valueArrayItem)) {
$isValid = false;
}
}
}
}
Expand Down

0 comments on commit f678fa9

Please sign in to comment.