import re


def validate_device_name(device_name):
    """Validates a given device name. Allowed characters are A-Z, a-z, _, - and 0-9. Minimum is
    one character, maximum are 64 characters. Removes all leading and trailing spaces before
    validation.

    Args:
        device_name: Device name to validate as string.

    Returns:
        True if the given string is an allowed device name, False if not.
    """

    if device_name is not None:
        search = re.compile(r'^[a-zA-Z_\-\d]{1,64}$').search
        return bool(search(device_name.strip()))
    return False