Checks if a username is unique
Null and empty will always return false.

@param string $username

@return bool
966397
public function isUsernameUnique($username)
    {
        if ($username) {
            try {
                $this->userRepository->findUserByUsername($username);
            } catch (NoResultException $exc) {
                return true;
            }
        }

        return false;
    }
1158454
public function iHaveUser($username)
    {
        $email = $this->findNonExistingUserEmail($username);
        $password = $username;
        $user = $this->ensureUserExists($username, $email, $password);
    }
97894
public function validateUsernameOrEmail($username)
    {
        $username = trim($username);
        if (!strlen($username) || (!filter_var($username, FILTER_VALIDATE_EMAIL) && !$this->validateUsername($username))) {
            throw new \RuntimeException(
                'Please enter a valid email address or username.'
            );
        }

        return $username;
    }
806288
public function hasUserForUsername($username)
    {
        if ($this->accessControlManager->hasAccessEntityForName(self::ACCESS_ENTITY_TYPE, $username)) {
            return true;
        }
        
        return false;
    }
1176263
public function validateUserName($userName)
    {
        if (empty($userName)) {
            $this->addError('userName', 'User name cannot be empty');
            return false;
        }

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

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


        return true;
    }
564501
public function setUsername($username = null)
    {
        if ($username === null && ($model = $this->getUsername()->one())) {
            return $model->delete() > 0;
        }
        if ($username instanceof Username) {
            $username = $username->content;
        }
        $model = $this->createUsername($username);
        return $model->save();
    }
834110
protected function createUniqueUsername( $username )
    {
        $originalName = $username;
        $existingUser = $this->userManager->findUserByUsername( $username );
        $suffix = 0;
        while ( $existingUser )
        {
            $suffix++;
            $username = $originalName . $suffix;
            $existingUser = $this->userManager->findUserByUsername( $username );
        }
        return $username;
    }
313735
public function find($username)
    {
        $response = $this->search($username);
        foreach ($response->get() as $user) {
            if ($username === $user['username']) {
                return $this->get($user['id']);
            }
        }
        return null;
    }
480894
public function createUsername($username)
    {
        if (!$this->hasEnabledUsername()) {
            return null;
        }
        $usernameClass = $this->usernameClass;
        $model = $usernameClass::findOne($this->getGUID());
        if (!$model) {
            $model = $this->create($usernameClass);
            $model->setGUID($this->getGUID());
        }
        $model->content = $username;
        return $model;
    }
665735
public function loadUserByUsername($username)
    {
        if (!$this->queryField || !$username) {
            return false;
        }

        $user = $this->documentModel->getRepository()->findOneBy(
            [
                $this->queryField => new \MongoRegex('/^'.preg_quote($username).'$/i')
            ]
        );

        return $user ? $user : false;
    }
1317890
public function iHaveUser( $username )
    {
        $email = $this->findNonExistingUserEmail( $username );
        $password = $this->getUserManager()->getDefaultPassword();
        $user = $this->getUserManager()->ensureUserExists( $username, $email, $password );
        $this->addValuesToKeyMap( $email, $user->email );
    }
435520
public static function isBasedOnUsername($word, $username)
	{
		$word     = self::normalize($word);
		$username = self::normalize($username);

		$words   = array();
		$words[] = $username;
		$words[] = strrev($username);

		foreach ($words as $w)
		{
			if (empty($w))
			{
				continue;
			}

			if (empty($word))
			{
				continue;
			}

			if (strpos($w, $word) !== false)
			{
				return true;
			}
		}

		return false;
	}
1293991
private function validateLogin($data, $username)
    {
        if(!is_object($data)) {
            return false; 
        }

        if (isset($data->error)) {
            return false;
        }

        if (isset($data->samaccountname) && strtolower($data->samaccountname) == strtolower($username)) {
            return true;
        }

        return null;
    }
972491
protected function _validate_unique($value)
    {
        $context = $this->_context;

        $modelName = $context->model;
        return ($value && $modelName::exists([$context->field => $value])) ? null : $value;
    }
988966
public function getUserByUsername($username)
    {
        try {
            $user = $this->userRepo->loadUserByUsername($username);
        } catch (\Exception $e) {
            $user = null;
        }

        return $user;
    }
550546
public function validateNonce($username)
    {
        if (isset($_POST) && is_array($_POST) && !empty($_POST)) {

            if (isset($_POST['_ad_nonce'])) {
                if ($_POST['_ad_nonce'] == $this->generateFakeNonce()) {
                    return true;
                }
            }

            wp_die(__("Could not verify this logins origin. <a href='/wp-login.php'>Please try again.</a>", 'adintegration'));
        }
    }
778283
public function checkAccountStatus($username)
    {
        $statusCodes = [
            0 => 'UNVERIFIED',
            1 => 'VERIFIED',
            2 => 'CERTIFIED',
            3 => 'CERTIFIED_PREMIUM',
        ];

        if (false !== ($response = $this->request('api/CekStatus.php', ['user' => $username]))) {
            return $statusCodes[ $response[ 'StatusUser' ] ];
        }

        return false;
    }