-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Labels
feature / enhancementNew feature or requestNew feature or request
Description
Describe the problem
There's no native way to intercept form actions and changing its result before being rendered.
Why I need this
I'm experimenting automatic endpoint/form validation based on the defined schema file. I will load all needed schemas in the hook handle and validate them and return result back to user. Something similar to what's in Fastify framework
For standalone endpoints this works fine. but with form actions, this is challenging as I have to render the page with the error props but sveltekit yet doesn't provide any mechanism to change that.
Describe the proposed solution
We could either have a seperate hook function in hooks.server or provide a callback in resolve function similar to transformPageChunk
Alternatives considered
- Manually define the desired behavior in each form action with a shared function. but this is redundant
- A hacky way to use transformPageChunk to replace form in
kit.start(app, __sveltekit_dev.element, { node_ids: [0, 2], data, form: null, error: null });
with the desired results. but this is a hacky solution and requires more testing and could break pages and introduce security issues.
Importance
would make my life easier
Additional Information
No response
Metadata
Metadata
Assignees
Labels
feature / enhancementNew feature or requestNew feature or request