def invalid_gps_lock(config, data):
    """
    Checks a gps_lock field to see if the payload has a lock

    The source key is config["source"], or "gps_lock" if that is not set.

    The fix is marked invalid if data[source] is not in the list config["ok"].
    """
    ok_list = config['ok']
    if not isinstance(ok_list, list):
        raise ValueError('ok should be a list')
    if 'source' in config:
        source = config['source']
    else:
        source = 'gps_lock'
    if data[source] not in ok_list:
        data['_fix_invalid'] = True
    return data
