Validates the given application name.

@param string $application Application name.

@return $this

@throws InvalidArgumentException Thrown if the application name is invalid.
480688
public function validateApplication($application)
    {
        if (!is_string($application)
            || strlen($application) > 256
            || strlen($application) < 1
        ) {
            throw new InvalidArgumentException(
                'Application name must be a non empty string of at most 256 ' .
                'characters',
                400
            );
        }

        return $this;
    }
235495
public function setApplication(Application $application = null)
    {
        parent::setApplication($application);

        if (!$this->getHelperSet()) {
            throw new \Exception('Helper set is not set.');
        }
        $this->getHelperSet()->set(new SimpleQuestionHelper());
    }
557517
public function setApplication(ApplicationInterface $application, $status = null)
    {
        $this->application = $application;
        $this->setTo(
            $application->getJob()->getUser()->getInfo()->getEmail(),
            $application->getJob()->getUser()->getInfo()->getDisplayName(false)
        );
        $this->setVariablesFromApplication($application);
        return $this;
    }
483965
public function setName($name)
    {
        if (is_scalar($name) || method_exists($name, '__toString')) {
            $this->name = (string) $name;
        } else {
            throw new InvalidArgumentException('The name must be a string.');
        }

        if ($this->name === '') {
            $this->name = 'Error';
        }

        return $this;
    }
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.'
            ));
        }
    }
604895
public function setName($name)
    {
        if (!is_string($name) && !is_null($name)) {
            throw new \InvalidArgumentException(__CLASS__ . ' ' . __METHOD__ . ': Not a string');
        }

        $this->name = $name;

        return $this;
    }
837436
public function setName($name)
    {
        if (!preg_match('/^' . self::REGEX_TAGNAME . '$/u', $name)) {
            throw new \InvalidArgumentException(
                'Invalid tag name supplied: ' . $name
            );
        }

        $this->tag = $name;

        return $this;
    }
201706
private function validate($controller,$app) {
        $rule = [];
        if($controller->hasProperty('_rule')) {
            $rule = $app->_rule;
        }

        $validate = null;
        if($controller->hasProperty('_validate')) {
            $validate = $app->_validate;
        }
        else {
            $rule and $validate = Validate::class;
        }

        if($validate) {
            $message = $controller->hasProperty('_message')?$app->_message:[];
            $validate = new $validate($rule,$message);
        }

        return $validate;
    }
218292
public function setType($type)
    {
        if ($type === null || $type === 'array') {
            $this->type = $type;

            return $this;
        }

        if ($this->isObjectNameValid($type) !== true) {
            throw new InvalidArgumentException('Parameter type is not valid.');
        }

        $this->type = $type;

        return $this;
    }
791138
protected function validateMethod($method)
    {
        if ($method === null) {
            return $method;
        }

        if (!is_string($method)) {
            throw new \InvalidArgumentException('Method should be a string.');
        }

        $method = strtoupper($method);

        if (!in_array($method, $this->allowMethods)) {
            throw new \InvalidArgumentException('Invalid HTTP method: ' . $method);
        }

        return $method;
    }
1105719
public function setApplication($app)
    {
        Argument::i()->test(1, 'string');

        $this->application = $app;
        return $this->setData($this->message);
    }
96388
public function setName($name)
	{
		if ( ! is_string($name))
		{
			throw new \InvalidArgumentException('The name must be a string');
		}

		Arr::set($this->attributes, 'name', $name);

		return $this;
	}
684605
private function validateOptions(array $options): void
    {
        foreach ($this->requiredOptions as $name) {
            if (!array_key_exists($name, $options)) {
                throw new InvalidArgumentException(sprintf('Required parameter "%s" is missing.', $name));
            }

            $this->{$name} = $options[$name];
        }
    }
799732
protected final void setApplicationName(String applicationName) throws IllegalArgumentException {
        validateNotEmpty(applicationName, "applicationName");
        synchronized (this) {
            properties.put(APPLICATION_NAME, applicationName);
        }
    }
275265
public function validate(...$args)
    {
        foreach ($args as $key) {
            $value = $this->getParameter($key);
            if (!isset($value)) {
                throw new InvalidRequestException("The $key parameter is required");
            }
        }
    }
781785
public function authenticate(array $config)
    {
        if (!$this->client) {
            throw new InvalidArgumentException('The client instance was not given to the application authenticator.');
        }

        if (!array_key_exists('clientId', $config) || !array_key_exists('clientSecret', $config)) {
            throw new InvalidArgumentException('The application authenticator requires a client id and secret.');
        }

        $this->client->authenticate($config['clientId'], $config['clientSecret'], Client::AUTH_URL_CLIENT_ID);

        return $this->client;
    }
768041
public function validateSpaces($name)
    {
        $string = $this->removeSpaces($name);
        if ($string == $name) {
            return $name;
        } else {
            throw new \InvalidArgumentException(
                sprintf(
                    'The name "%s" is invalid, spaces between words are not allowed.',
                    $name
                )
            );
        }
    }