Validate the bucket name according to the rules stated at
https://developers.google.com/storage/docs/bucketnaming.

@param string $bucket_name The Google Cloud Storage bucket name.

@access private
333431
private static function validateBucketName($bucket_name) {
    $valid_bucket_regex = '/^[a-z0-9]+[a-z0-9\.\-_]+[a-z0-9]+$/';
    if (preg_match($valid_bucket_regex, $bucket_name) === 0) {
      return false;
    }

    if (strpos($bucket_name, 'goog') === 0) {
      return false;
    }

    if (filter_var($bucket_name, FILTER_VALIDATE_IP) !== false) {
      return false;
    }

    $parts = explode('.', $bucket_name);
    if (count($parts) > 1) {
      if (strlen($bucket_name) > 222) {
        return false;
      }
    }

    foreach ($parts as $part) {
      if (strlen($part) > 63) {
        return false;
      }
    }

    return true;
  }
328855
protected function isNameValid($name)
    {
        if (is_string($name) === false) {
            return false;
        }

        $match = preg_match(self::PATTERN_VALIDATE_NAME, $name);
        if ($name === '' || $match === false || $match <= 0) {
            return false;
        } else {
            return true;
        }
    }
1227382
def remove_bucket(self, bucket_name):
        
        is_valid_bucket_name(bucket_name)
        self._url_open('DELETE', bucket_name=bucket_name)

        # Make sure to purge bucket_name from region cache.
        self._delete_bucket_region(bucket_name)
505634
protected function validateName($name)
    {
        if (!ApiKey::isValidName($name)) {
            return self::MESSAGE_ERROR_INVALID_NAME;
        }
        if (!ApiKey::nameExists($name)) {
            return self::MESSAGE_ERROR_NAME_DOES_NOT_EXIST;
        }
        return null;
    }
744617
def bucket_exists(self, bucket_name):
        
        is_valid_bucket_name(bucket_name)

        try:
            self._url_open('HEAD', bucket_name=bucket_name)
        # If the bucket has not been created yet, MinIO will return a "NoSuchBucket" error.
        except NoSuchBucket:
            return False
        except ResponseError:
            raise
        return True
622660
protected function assertValidName($name)
    {
        if (!is_string($name) && $name !== null) {
            $actualType = is_object($name) ? get_class($name) : gettype($name);
            $message = $this->translator()->translate(
                '{{ parameter }} must be a {{ expectedType }}, received {{ actualType }}',
                [
                    '{{ parameter }}'    => '"name"',
                    '{{ expectedType }}' => 'string',
                    '{{ actualType }}'   => $actualType,
                ]
            );

            throw new InvalidArgumentException($message, 400);
        }
    }
1009066
protected function _validate($name, $attrName)
    {
        if( ! empty($this->validate) )
        {
            $validate[$name]           = $this->validate;
            $validate[$name]['value']  = $this->settings['attr']['alias'] ?? $attrName;

            $session = Singleton::class('ZN\Storage\Session');

            $session->insert('FormValidationMethod', $this->method);
            $session->insert('FormValidationRules' , array_merge($session->select('FormValidationRules') ?: $validate, $validate));
 
            $this->validate = [];
        }
    }
1341564
public static function SetExtensionName($name)
    {
        self::CheckBackend();

        $name = trim($name);

        self::$backend->Set("name", $name);
    }
193882
public static function validName(string $name): bool
    {
        $enumerables = self::getCache();
        $keys = array_keys($enumerables);

        return \in_array($name, $keys, true);
    }
167629
public function valid($file_names) {
		$valid = true;
		if(is_array($file_names)) {
			foreach($file_names as $name) {
				if(!$this->_valid($name)) {
					$valid = false;
					break;
				}
			}
		} else {
			$valid = $this->_valid($file_names);
		}
		return $valid;
	}
1188422
protected function validateNameRename()
    {
        $files = $this->getSubmitted('files');

        /* @var $file \SplFileInfo */
        $file = reset($files);
        $name = $this->getSubmitted('name');

        if (strlen($name) == 0) {
            $this->setErrorRequired('name', $this->translation->text('Name'));
            return false;
        }

        $pattern = $file->isFile() ? '/^[\w-.]+$/' : '/^[\w-]+$/';

        if (preg_match($pattern, $name) !== 1) {
            $this->setErrorInvalid('name', $this->translation->text('Name'));
            return false;
        }

        return true;
    }
329764
private function validateTableName($name)
    {
        if (! is_string($name)) {
            throw InvalidArgumentException::invalidType('key', 'string', $name);
        }

        if (! preg_match('/^[a-z0-9_.-]{3,255}$/i', $name)) {
            throw InvalidArgumentException::invalidTableName($name);
        }
    }
92918
private void removeBucket(String name)
    {
        try
        {
            if (clusterManager.removeBucket(name))
            {
                LOGGER.info("Bucket [" + name + "] is removed!");
            }
            else
            {
                LOGGER.error("Not able to remove bucket [" + name + "].");
                throw new KunderaException("Not able to remove bucket [" + name + "].");
            }
        }
        catch (CouchbaseException ex)
        {
            LOGGER.error("Not able to remove bucket [" + name + "].", ex);
            throw new KunderaException("Not able to remove bucket [" + name + "].", ex);
        }
    }
575326
private function __dnsBucketName($bucket)
	{
		if (strlen($bucket) > 63 || preg_match("/[^a-z0-9\.-]/", $bucket) > 0) return false;
		if (S3::$useSSL && strstr($bucket, '.') !== false) return false;
		if (strstr($bucket, '-.') !== false) return false;
		if (strstr($bucket, '..') !== false) return false;
		if (!preg_match("/^[0-9a-z]/", $bucket)) return false;
		if (!preg_match("/[0-9a-z]$/", $bucket)) return false;
		return true;
	}
166433
private function validateSettingName($name)
    {
        if (!isset($this->settingsSchema[$name])) {
            return new ValidationError(
                "Setting '%setting%' is unknown",
                null,
                [
                    '%setting%' => $name,
                ],
                "[$name]"
            );
        }

        return null;
    }
910249
public function validateName()
    {
        $value = $this->name;
        if ($this->manager->getRole($value) !== null || $this->manager->getPermission($value) !== null) {
            $message = Yii::t('yii', '{attribute} "{value}" has already been taken.');
            $params = [
                'attribute' => $this->getAttributeLabel('name'),
                'value' => $value,
            ];
            $this->addError('name', Yii::$app->getI18n()->format($message, $params, Yii::$app->language));
        }
    }
908964
public function validateName($name)
    {
        if (empty($name)) {
            $this->addError('name', 'Name cannot be empty');
            return false;
        }

        if (!is_string($name)) {
            $this->addError('name', 'Name must be a string');
            return false;
        }

        if (mb_strlen($name, 'UTF-8') > 255) {
            $this->addError('name', 'Name length has to be less or equal to 255');
            return false;
        }


        return true;
    }