diff --git a/src/schemas/compute-functions.ts b/src/schemas/compute-functions.ts index f34056e..6cf5b07 100644 --- a/src/schemas/compute-functions.ts +++ b/src/schemas/compute-functions.ts @@ -25,9 +25,9 @@ export const computeAddTodo = (data: any) => ({ completed: false, }) -export const updateFilterQuery = (_: any, event: any) => event.target.value +export const updateFilterQuery = (_: any, event: any) => event?.target?.value || '' -export const updateNewTodo = (data: any, event: any) => event.target.value +export const updateNewTodo = (data: any, event: any) => event?.target?.value || '' export const checkCanAddTodo = (data: any) => data.newTodo?.trim().length > 0 diff --git a/src/schemas/schema-loader.ts b/src/schemas/schema-loader.ts index 1ef5cf4..085ff98 100644 --- a/src/schemas/schema-loader.ts +++ b/src/schemas/schema-loader.ts @@ -4,6 +4,15 @@ import * as computeFunctions from './compute-functions' type ComputeFunctionMap = typeof computeFunctions export function hydrateSchema(jsonSchema: any): PageSchema { + // Validate basic schema structure + if (!jsonSchema || typeof jsonSchema !== 'object') { + throw new Error('Invalid schema: expected an object') + } + + if (!jsonSchema.id || !jsonSchema.name) { + console.warn('Schema missing required fields: id and name') + } + const schema = { ...jsonSchema } if (schema.dataSources) {