import re


def is_valid_username(username):
    """
    Validate username with provided requirements
    :param username: username of user trying to login
    :return: true if the username is acceptable, false otherwise
    """
    return (
        # r2.8 requirement
        2 < len(username) < 20 and
        # does not start or end with space
        username[0] != ' ' and
        username[-1] != ' ' and
        # is alphanumeric (plus space)
        bool(re.match(r'^[\w\d ]+$', username))
    )