def valid_username(user):
    if not isinstance(user, string_types):
        return False

    if len(user) > 32:
        return False

    return VALID_USERNAME.match(user) is not None
Validates a username based on the guidelines in `useradd(8)`
dataset/ETHPy150Open saltstack/salt/salt/utils/validate/user.py/valid_username