Question · Svelte and SvelteKit course · Module 13: Form Actions
Validation Error in a Form Action
How do you return a validation error from a form action?
Answer options
- throw new Error('message')
- return fail(400, { error: 'message' })
- return { error: true }
- throw fail(400)
You can check the correct answer by solving this task in the CodeWorlds game.