def _make_trigger_for_user_properties(insert_or_update, table, column):
    'Return a CREATE TRIGGER statement to check TEXT_USERPROPERTIES\n    values. This trigger is used to check values before they are saved\n    in the database.\n\n    A wellformed TEXT_USERPROPERTIES value is a string containing\n    a JSON formatted object.\n\n    The trigger will pass without error if the value is wellformed.\n    '
    if SQLITE_JSON1_ENABLED:
        user_properties_check = f"(json_valid(NEW.{column}) = 0 OR json_type(NEW.{column}) != 'object')"
    else:
        user_properties_check = f'is_wellformed_user_properties(NEW.{column}) = 0'
    return f'''
        CREATE TEMPORARY TRIGGER IF NOT EXISTS trigger_check_{insert_or_update.lower()}_{table}_{column}
        BEFORE {insert_or_update.upper()} ON main.{table} FOR EACH ROW
        WHEN
            NEW.{column} IS NOT NULL
            AND {user_properties_check}
        BEGIN
            SELECT RAISE(ABORT, '{table}.{column} must be wellformed JSON object');
        END;
    '''
Return a CREATE TRIGGER statement to check TEXT_USERPROPERTIES
values. This trigger is used to check values before they are saved
in the database.

A wellformed TEXT_USERPROPERTIES value is a string containing
a JSON formatted object.

The trigger will pass without error if the value is wellformed.
def _make_trigger_for_user_properties(insert_or_update, table, column):
    'Return a CREATE TRIGGER statement to check TEXT_USERPROPERTIES\n    values. This trigger is used to check values before they are saved\n    in the database.\n\n    A wellformed TEXT_USERPROPERTIES value is a string containing\n    a JSON formatted object.\n\n    The trigger will pass without error if the value is wellformed.\n    '
    if SQLITE_JSON1_ENABLED:
        user_properties_check = f"(json_valid(NEW.{column}) = 0 OR json_type(NEW.{column}) != 'object')"
    else:
        user_properties_check = f'is_wellformed_user_properties(NEW.{column}) = 0'
    return f'
        CREATE TEMPORARY TRIGGER IF NOT EXISTS trigger_check_{insert_or_update.lower()}_{table}_{column}
        BEFORE {insert_or_update.upper()} ON main.{table} FOR EACH ROW
        WHEN
            NEW.{column} IS NOT NULL
            AND {user_properties_check}
        BEGIN
            SELECT RAISE(ABORT, '{table}.{column} must be wellformed JSON object');
        END;
    '