def METHOD_NAME(vendor, type, devname, device):
    for method in device['upload_methods']:
        if method not in ['stlink', 'dfu', 'uart', 'wifi', 'betaflight', 'stock']:
            error(f'Invalid upload method "{method}" for target "{vendor}.{type}.{devname}"')
    if 'stlink' not in device['upload_methods']:
        error(f'STM32 based devices must always have "stlink" as an upload_method for target "{vendor}.{type}.{devname}"')
    if 'stlink' not in device:
        error(f'STM32 based devices must always have "stlink" attribute for target "{vendor}.{type}.{devname}"')
    else:
        stlink = device['stlink']
        if 'cpus' not in stlink:
            error(f'The "stlink" attribute for target "{vendor}.{type}.{devname}" must have a list of valid "cpus"')
        if 'offset' not in stlink:
            error(f'The "stlink" attribute for target "{vendor}.{type}.{devname}" must have a valid "offset"')
        if 'bootloader' not in stlink:
            error(f'The "stlink" attribute for target "{vendor}.{type}.{devname}" must have a valid "bootloader"')
    # could check the existence of the bootloader file