Determines whether the @string pattern is username-like
        @string: #str being tested
        @minlen: minimum required username length
        @maxlen: maximum username length

        -> #bool
344490
def is_username(string, minlen=1, maxlen=15):
    
    if string:
        string = string.strip()
        return username_re.match(string) and (minlen <= len(string) <= maxlen)
    return False
538480
public void expectMax(String name, double maxLength) {
        expectMax(name, maxLength, messages.get(Validation.MAX_KEY.name(), name, maxLength));
    }
1323228
public static function isLength($string = false, $minLength = 0, $maxLength = false) {

        if ($string && strlen($string) >= $minLength) {

            if (!$maxLength || strlen($string) <= $maxLength) {

                return true;
            }
        }

        return false;
    }
512246
def input_validate_str(string, name, max_len=None, exact_len=None):
    
    if type(string) is not str:
        raise pyhsm.exception.YHSM_WrongInputType(name, str, type(string))
    if max_len != None and len(string) > max_len:
        raise pyhsm.exception.YHSM_InputTooLong(name, max_len, len(string))
    if exact_len != None and len(string) != exact_len:
        raise pyhsm.exception.YHSM_WrongInputSize(name, exact_len, len(string))
    return string
414113
def _generate_username(self):
        
        while True:
            # Generate a UUID username, removing dashes and the last 2 chars
            # to make it fit into the 30 char User.username field. Gracefully
            # handle any unlikely, but possible duplicate usernames.
            username = str(uuid.uuid4())
            username = username.replace('-', '')
            username = username[:-2]

            try:
                User.objects.get(username=username)
            except User.DoesNotExist:
                return username
258118
private function __validateString($string, $minLength = 1, $maxLength = 0)
    {
        if (!is_string($string)) {
            $this->error = 'parameter is not string.';
            return false;
        } else if ($maxLength > 0 && strlen($string) > $maxLength) {
            $this->error = 'parameter is too long. string:' . $string;
            return false;
        } else if (strlen($string) < $minLength) {
            $this->error = 'parameter is too short. string:' . $string;
            return false;
        }
        return true;
    }
540443
public boolean isUserGuest(String userName) {

        if (CmsStringUtil.isEmptyOrWhitespaceOnly(userName)) {
            return false;
        }
        return m_userGuest.equals(userName);
    }
388078
private static function myValidateUsername(string $username, ?string &$error = null): bool
    {
        if ($username === '') {
            $error = 'Username "" is empty.';

            return false;
        }

        if (strpos($username, '..') !== false) {
            $error = 'Username "' . $username . '" contains "..".';

            return false;
        }

        if (strlen($username) > 64) {
            $error = 'Username "' . $username . '" is too long: Maximum length is 64.';

            return false;
        }

        if (preg_match('/[^0-9a-zA-Z.!#$%&\'*+\/=?^_`{|}~-]/', $username, $matches)) {
            $error = 'Username "' . $username . '" contains invalid character "' . $matches[0] . '".';

            return false;
        }

        return true;
    }
137033
def validateMemberName(n):
    
    try:
        if len(n) < 1:
            raise Exception('Name must be at least one byte in length')
        if len(n) > 255:
            raise Exception('Name exceeds maximum length of 255')
        if n[0].isdigit():
            raise Exception('Names may not begin with a digit')
        if mbr_re.search(n):
            raise Exception(
                'Names contains a character outside the set [A-Za-z0-9_]')
    except Exception as e:
        raise MarshallingError('Invalid member name "%s": %s' % (n, str(e)))
1205084
def is_uid(str):
    

    import re

    if len(str)!=16:
       return False

    pattern = r'[^\.a-f0-9]'
    if re.search(pattern, str.lower()):
        return False

    return True
544139
def __verify_username(self, username):
        """"""

        if len(username) > self.__max_length or len(username) < 3:
            raise ValueError(
                f"Username must be between 3 and {self.__max_length} characters."
            )
        if any(c not in string.ascii_letters + string.digits for c in username):
            raise ValueError("Usernames can only contain alphanumeric characters.")
406494
public static function check_name(): bool
  {

    $args = \func_get_args();
    // Each argument must be a string starting with a letter, and having only one character made of letters, numbers and underscores
    foreach ( $args as $a ){
      $a = self::cast($a);
      $t = preg_match('#[A-z0-9_]+#',$a,$m);
      if ( $t !== 1 || $m[0] !== $a ){
        return false;
      }
    }

    return true;
  }
977556
public static function string($val, $minLen = 0, $maxLen = null): bool
    {
        if (!\is_string($val)) {
            return false;
        }

        // only type check.
        if ($minLen === 0 && $maxLen === null) {
            return true;
        }

        return self::integer(Helper::strlen($val), $minLen, $maxLen);
    }
821707
def username(self, value):
        
        self._username = value
        self._connectionXML.set('username', value)
368975
def is_user(value, min=None, max=None):
    

    if type(value) == str:
        try:
            entry = pwd.getpwnam(value)
            value = entry.pw_uid
        except KeyError:
            err_message = ('{0}: No such user.'.format(value))
            raise validate.VdtValueError(err_message)

        return value

    elif type(value) == int:
        try:
            pwd.getpwuid(value)
        except KeyError:
            err_message = ('{0}: No such user.'.format(value))
            raise validate.VdtValueError(err_message)

        return value

    else:
        err_message = ('Please, use str or int to "user" parameter.')
        raise validate.VdtTypeError(err_message)
821860
def has_perm(self, username, perm, path=None):
        
        account = self.get_account(username)
        return account and account.has_perm(perm, path)
1295953
def checkpat(self, pattern):
        
        if pattern is None:
            return
        try:
            re.match(pattern, "")
        except re.error:
            print3("\nBad user-defined singular pattern:\n\t%s\n" % pattern)
            raise BadUserDefinedPatternError