src/RulesCollection.php
private function getNestedErrors(string $key, array $scope, array $input): array
    {
        $parts = explode('.', $key);
        $current = array_shift($parts);
        $next = implode('.', $parts);

        // The current part is * and there is still some parts, rune the
        // validation on each nested value.
        if ($current == '*' && count($parts) > 0) {

            $errors = [];

            foreach ($scope as $key => $nested) {

                $new_errors = $this->getNestedErrors($next, $nested, $input);

                $errors = array_merge($errors, $new_errors);

            }

            return $errors;

        }

        // There is still some parts, run the validation on the nested value.
        if (count($parts) > 0) {

            return $this->getNestedErrors($next, $scope[$current] ?? [], $input);

        }

        // There is no more parts, run the validation on the current scope.
        return $this->getErrors($current, $scope, $input);
    }
private function getNestedErrors(string $key, array $scope, array $input): array
    {
        $parts = explode('.', $key);
        $current = array_shift($parts);
        $next = implode('.', $parts);

        // The current part is * and there is still some parts, rune the
        // validation on each nested value.
        if ($current == '*' && count($parts) > 0) {

            $errors = [];

            foreach ($scope as $key => $nested) {

                $new_errors = $this->getNestedErrors($next, $nested, $input);

                $errors = array_merge($errors, $new_errors);

            }

            return $errors;

        }

        // There is still some parts, run the validation on the nested value.
        if (count($parts) > 0) {

            return $this->getNestedErrors($next, $scope[$current] ?? [], $input);

        }

        // There is no more parts, run the validation on the current scope.
        return $this->getErrors($current, $scope, $input);
    }
private function getNestedErrors ( string $ key , array $ scope , array $ input ) : array { $ parts = explode ( '.' , $ key ) ; $ current = array_shift ( $ parts ) ; $ next = implode ( '.' , $ parts ) ; // The current part is * and there is still some parts, rune the // validation on each nested value. if ( $ current == '*' && count ( $ parts ) > 0 ) { $ errors = [ ] ; foreach ( $ scope as $ key => $ nested ) { $ new_errors = $ this -> getNestedErrors ( $ next , $ nested , $ input ) ; $ errors = array_merge ( $ errors , $ new_errors ) ; } return $ errors ; } // There is still some parts, run the validation on the nested value. if ( count ( $ parts ) > 0 ) { return $ this -> getNestedErrors ( $ next , $ scope [ $ current ] ?? [ ] , $ input ) ; } // There is no more parts, run the validation on the current scope. return $ this -> getErrors ( $ current , $ scope , $ input ) ; }
Go deeper in the input array for each dot in the rule key. Run the
validation when on the last part of the rule key.

@param string    $key
@param array     $scope
@param array     $input
@return array
Go deeper in the input array for each dot in the rule key . Run the validation when on the last part of the rule key .