mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 09:31:13 -05:00
Fix: Resolve form validation and type errors
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { serve } from "https://deno.land/std@0.190.0/http/server.ts";
|
||||
import { createClient } from "https://esm.sh/@supabase/supabase-js@2.57.4";
|
||||
import { validateEntityData } from "./validation.ts";
|
||||
|
||||
const corsHeaders = {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
@@ -205,6 +206,12 @@ serve(async (req) => {
|
||||
try {
|
||||
console.log(`Processing item ${item.id} of type ${item.item_type}`);
|
||||
|
||||
// Validate entity data before processing
|
||||
const validation = validateEntityData(item.item_type, item.item_data);
|
||||
if (!validation.valid) {
|
||||
throw new Error(`Validation failed: ${validation.errors.join(', ')}`);
|
||||
}
|
||||
|
||||
// Set user context for versioning trigger
|
||||
// This allows auto_create_entity_version() to capture the submitter
|
||||
const { error: setConfigError } = await supabase.rpc('set_config_value', {
|
||||
|
||||
Reference in New Issue
Block a user