UNPKG

supastash

Version:

Offline-first sync engine for Supabase in React Native using SQLite

33 lines (32 loc) 1.24 kB
/** * Validates the payload * @param payload - The payload to validate */ export async function validatePayload(payload) { if (!payload.id) { throw new Error("Unique 'id' column of type uuid/text is required"); } if (!payload.updated_at) { throw new Error("'updated_at' column of type timestampz is required"); } if (!payload.created_at) { throw new Error("'created_at' column of type timestampz is required"); } if (!payload.deleted_at) { throw new Error("'deleted_at' column of type timestampz is required"); } } export function validatePayloadForTable(payload) { if (!payload.some((col) => col.column_name === "id")) { throw new Error("Unique 'id' column of type uuid/text is required"); } if (!payload.some((col) => col.column_name === "updated_at")) { throw new Error("'updated_at' column of type timestampz is required"); } if (!payload.some((col) => col.column_name === "created_at")) { throw new Error("'created_at' column of type timestampz is required"); } if (!payload.some((col) => col.column_name === "deleted_at")) { throw new Error("'deleted_at' column of type timestampz is required"); } }