Checks config against validation rules

@param array $config
@throws ServiceConfigurationException
174389
protected function validateConfig(array $config)
    {
        $validator = Validator::make($config, $this->getConfigValidationRules());

        if ($validator->fails()) {

            throw new ServiceConfigurationException(
                'Invalid configuration: ' . print_r($validator->messages()->toArray(), true),
                $validator->messages()->toArray()
            );
        }
    }
151815
protected function validateConfig($config)
    {
        if (empty(array_get($config, 'base_url'))) {
            throw new InternalServerErrorException('No base url provided for GitLab client.');
        }
        if (empty(array_get($config, 'token'))) {
            throw new InternalServerErrorException('No token provided for GitLab client.');
        }
    }
1263792
public function setConfig(array $config)
    {
        foreach ($config as $key => $value) {
            switch ($key) {
                case 'verbose':
                case 'loadEnv':
                    if (!is_bool($value)) {
                        throw new ConfigurationException($key, 'This should be a boolean value.');
                    }

                    $this->config[$key] = $value;
                    break;

                default:
                    throw new ConfigurationException($key, 'This is an unknown configuration option.');
            }
        }
    }
489477
private function validateDefinitionConfig($name, array &$config)
    {
        if (true === $config['virtual'] && 0 === count($config['property_paths'])) {
            throw new \InvalidArgumentException(sprintf('"property_paths" must be set for "virtual" characteristic "%s".', $name));
        }
        if ($config['type'] === 'datetime') {
            if ($config['format'] === '%s') {
                $config['format'] = 'd/m/Y';
            }
        } elseif (false === strpos($config['format'], '%s')) {
            throw new \InvalidArgumentException(sprintf('"format" must contain "%%s" for characteristic "%s".', $name));
        }
    }
794634
public static function setConfig($config = [])
    {
        if (!is_array($config)) {
            return false;
        }
        self::$config = array_merge(self::$config, $config);
        return true;
    }
919394
protected function validateConfig(array $config)
    {
        // For now it's only required to pass a filter form type class.
        // If you don't want to use a defined form type class,
        // you can override the FormCreator object, implement FormCreatorInterface and customize it.
        $requiredKeys = ['form_filter_type_class'];

        foreach ($requiredKeys as $key) {
            if (!array_key_exists($key, $config)) {
                throw new FormCreatorException(sprintf(
                    'Key "%s" must be presented in the filters configuration.', $key
                ));
            }

            if (!class_exists($config[$key])) {
                throw new FormCreatorException(sprintf('Class "%s" is not found.', $config[$key]));
            }
        }
    }
12701
static public function validateClientConfig(array $config)
    {
        $tags = [static::T8700, static::T8915, static::T8914];

        foreach ($tags as $tag) {
            if (!array_key_exists($tag, $config) || empty($config[$tag])) {
                throw new InvalidArgumentException("Please configure value for tag " . $tag);
            }
        }
    }
210031
protected function findServiceIds(array $config, array &$serviceIds)
    {
        foreach ($config as $name => $value) {
            if (is_array($value)) {
                $this->findServiceIds($value, $serviceIds);
            } elseif ($name === 'service_id') {
                $serviceIds[] = $value;
            }
        }
    }
398810
protected function processConfig(array $config)
    {
        // set defaults as an array if not provided
        if (!isset($config['defaults'])) {
            $config['defaults'] = [];
        }

        // Add the handlers based on the configuration option
        $stack = $this->getHandlerStack();

        if (!isset($config['validate']) || $config['validate'] === true) {
            $stack->push(new ValidatedDescriptionHandler($this->description), 'validate_description');
        }

        if (!isset($config['process']) || $config['process'] === true) {
            // TODO: This belongs to the Deserializer and should be handled there.
            // Question: What is the result when the Deserializer is bypassed?
            // Possible answer: The raw response.
        }
    }
407082
protected function validateServerConfig($config)
    {
        if (!is_array($config)) {
            throw new InvalidArgumentException($this->translate(
                'Server configuration should be an array or Traversable.'
            ));
        }
        if (!isset($config['id']) || empty($config['id'])) {
            throw new InvalidArgumentException($this->translate(
                'Cannot find server id in configuration.'
            ));
        }
        if (!isset($config['connection']) || empty($config['connection'])) {
            throw new InvalidArgumentException($this->translate(
                'Cannot find connection type in configuration.'
            ));
        }
    }
1157288
private function checkConfigKeys($config)
    {
        $config = array_change_key_case($config, CASE_LOWER);
        $config = $this->trimArray($config);

        foreach ($config as $key => $value) {
            if (array_key_exists($key, $this->config)) {
                $this->config[$key] = $value;
            } else {
                throw new \Exception('Key ' . $key . ' is either not part of the configuration or has incorrect Key name.
                check the config array key names to match your key names of your config array', 1);
            }
        }
    }
398051
public function validator($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'debug' => JFactory::getApplication()->getCfg('debug')
        ));

        return parent::validator($config);
    }
276998
public function config(array $config): void
    {
        if ($this->routeCounter > 0) {
            throw new \LogicException('Routing has been added, and configuration is not allowed!');
        }

        $props = [
            'name'                   => 1,
            'chains'                 => 1,
            // 'defaultRoute'           => 1,
            'ignoreLastSlash'        => 1,
            'tmpCacheNumber'         => 1,
            'handleMethodNotAllowed' => 1,
            'autoRoute'              => 1,
            'controllerNamespace'    => 1,
            'controllerSuffix'       => 1,
        ];

        foreach ($config as $name => $value) {
            if (isset($props[$name])) {
                $this->$name = $value;
            }
        }
    }
1288009
private function validateEachCanonicalLocaleExists(array $config)
    {
        $canonicals = $config['canonicals'] ?? [];
        foreach ($canonicals as $locale => $canonical) {
            if (!$this->existsAsLocale($config['locales'], $locale)) {
                throw new InvalidConfig('Canonical key '.$locale.' is not present as locale.');
            }
        }
    }
310220
public function _validate_config($config)
	{
		$validated = array();

		foreach ($config as $name => $item)
		{
			if ($name == 'memcached' and is_array($item))
			{
				foreach ($item as $name => $value)
				{
					switch ($name)
					{
						case 'cookie_name':
							if ( empty($value) or ! is_string($value))
							{
								$value = 'fuelmid';
							}
						break;

						case 'servers':
							// do we have a servers config
							if ( empty($value) or ! is_array($value))
							{
								$value = array('default' => array('host' => '127.0.0.1', 'port' => '11211'));
							}

							// validate the servers
							foreach ($value as $key => $server)
							{
								// do we have a host?
								if ( ! isset($server['host']) or ! is_string($server['host']))
								{
									throw new \FuelException('Invalid Memcached server definition in the session configuration.');
								}
								// do we have a port number?
								if ( ! isset($server['port']) or ! is_numeric($server['port']) or $server['port'] < 1025 or $server['port'] > 65535)
								{
									throw new \FuelException('Invalid Memcached server definition in the session configuration.');
								}
								// do we have a relative server weight?
								if ( ! isset($server['weight']) or ! is_numeric($server['weight']) or $server['weight'] < 0)
								{
									// set a default
									$value[$key]['weight'] = 0;
								}
							}
						break;

						default:
							// unknown property
							continue;
					}

					$validated[$name] = $value;
				}
			}
			else
			{
				// skip all config array properties
				if (is_array($item))
				{
					continue;
				}

				// global config, was validated in the driver
				$validated[$name] = $item;
			}

		}

		// validate all global settings as well
		return parent::_validate_config($validated);
	}
951933
private function configure(array $config = []): void
    {
        foreach ($config as $param => $value) {
            $property = $this->toCamelCase($param);
            if (property_exists(self::class, $property)) {
                $this->$property = $value;
            }
        }
    }
1122321
public function loadConfiguration(array $config = [])
    {
        parent::loadConfiguration($config);
        if (isset($config['auto'])) {
            $this->setAutoLogin((bool) $config['auto']);
        }
        if (isset($config['identityClass'])) {
            $this->setIdentityClass($config['identityClass']);
        }
    }