src/Viserio/Component/OptionsResolver/Traits/OptionsResolverTrait.php
private static function validateOptions(array $validators, $config, string $configClass): void
    {
        foreach ($validators as $key => $values) {
            if (! \array_key_exists($key, (array) $config)) {
                continue;
            }

            if (\is_array($values) && isset($values[0]) && \is_string($values[0])) {
                $hasError = false;

                foreach ($values as $check) {
                    if ($hasError === false && \array_key_exists($check, self::$defaultTypeMap)) {
                        $fn       = self::$defaultTypeMap[$check];
                        $hasError = $fn($config[$key]);
                    }
                }

                if (! $hasError) {
                    throw InvalidArgumentException::invalidType($key, $config[$key], $values, $configClass);
                }

                continue;
            }

            if (\is_callable($values)) {
                $values($config[$key], $key);

                continue;
            }

            if (! \is_array($values) && ! \is_callable($values)) {
                throw new InvalidValidatorException(\sprintf(
                    'The validator must be of type callable or string[]; [%s] given, in [%s].',
                    \is_object($values) ? \get_class($values) : \gettype($values),
                    $configClass
                ));
            }

            self::validateOptions((array) $values, $config[$key], $configClass);
        }
    }
private static function validateOptions(array $validators, $config, string $configClass): void
    {
        foreach ($validators as $key => $values) {
            if (! \array_key_exists($key, (array) $config)) {
                continue;
            }

            if (\is_array($values) && isset($values[0]) && \is_string($values[0])) {
                $hasError = false;

                foreach ($values as $check) {
                    if ($hasError === false && \array_key_exists($check, self::$defaultTypeMap)) {
                        $fn       = self::$defaultTypeMap[$check];
                        $hasError = $fn($config[$key]);
                    }
                }

                if (! $hasError) {
                    throw InvalidArgumentException::invalidType($key, $config[$key], $values, $configClass);
                }

                continue;
            }

            if (\is_callable($values)) {
                $values($config[$key], $key);

                continue;
            }

            if (! \is_array($values) && ! \is_callable($values)) {
                throw new InvalidValidatorException(\sprintf(
                    'The validator must be of type callable or string[]; [%s] given, in [%s].',
                    \is_object($values) ? \get_class($values) : \gettype($values),
                    $configClass
                ));
            }

            self::validateOptions((array) $values, $config[$key], $configClass);
        }
    }
Run a validator against given config.

@param array<string => array<int => string>, string => callback> $validators
@param array|\ArrayAccess                                        $config
@param string                                                    $configClass

@throws \Viserio\Component\Contract\OptionsResolver\Exception\InvalidValidatorException

@return void