public function assertUsername($username, $config)
    {
        if (!is_string($username)) {
            throw new ConfigurationException("Username $username must be a string.");
        }
        $len = strlen($username);
        $minLen=$config["registration"]["nameLenMin"];
        $maxLen=$config["registration"]["nameLenMax"];
        if ($len < $minLen || $len > $maxLen) {
            throw new ConfigurationException(
                sprintf("Length of a username $username must be between %d-%d characters.", $minLen, $maxLen)
            );
        }
        if (!$this->checkValidNameFormat($username)) {
            throw new ConfigurationException("Username $username contains invalid character/s.");
        }
    }