Fix Action Validation Error Handling #14

Merged
schreifuchs merged 4 commits from issue-3 into main 2026-04-03 17:27:28 +02:00
2 changed files with 4 additions and 4 deletions
Showing only changes of commit 7492680457 - Show all commits
+2 -2
View File
@@ -1,6 +1,6 @@
import { db } from '$lib/server/db'; import { db } from '$lib/server/db';
import { aktis, ratings } from '$lib/server/db/schema'; import { aktis, ratings } from '$lib/server/db/schema';
import { error, redirect, type Actions } from '@sveltejs/kit'; import { error, fail, redirect, type Actions } from '@sveltejs/kit';
import { and, eq } from 'drizzle-orm'; import { and, eq } from 'drizzle-orm';
import type { PageServerLoad } from './$types'; import type { PageServerLoad } from './$types';
import { ensureAuth } from '$lib/auth'; import { ensureAuth } from '$lib/auth';
@@ -54,7 +54,7 @@ export const actions = {
) )
).data; ).data;
if (!changeRequest) return error(400); if (!changeRequest) return fail(400, { message: 'Invalid data' });
await db await db
.update(aktis) .update(aktis)
@@ -1,6 +1,6 @@
import type { PageServerLoad } from './$types'; import type { PageServerLoad } from './$types';
import { ensureAuth } from '$lib/auth'; import { ensureAuth } from '$lib/auth';
import { error, redirect, type Actions } from '@sveltejs/kit'; import { error, fail, redirect, type Actions } from '@sveltejs/kit';
import { extractFormData } from '$lib/extractFormData'; import { extractFormData } from '$lib/extractFormData';
import { aktis, ratings } from '$lib/server/db/schema'; import { aktis, ratings } from '$lib/server/db/schema';
import { eq } from 'drizzle-orm'; import { eq } from 'drizzle-orm';
@@ -54,7 +54,7 @@ export const actions = {
) )
).data; ).data;
if (!rating) return error(400); if (!rating) return fail(400, { message: 'Invalid data' });
await db.insert(ratings).values({ await db.insert(ratings).values({
...rating, ...rating,