Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Abstract form action logic #7

Open
bbtgnn opened this issue Jun 24, 2023 · 0 comments
Open

Abstract form action logic #7

bbtgnn opened this issue Jun 24, 2023 · 0 comments
Assignees

Comments

@bbtgnn
Copy link
Collaborator

bbtgnn commented Jun 24, 2023

Many form actions share the same structure:

const data = await request.formData();
const form = await superValidate(data, registerSchema);

if (!form.valid) {
    return fail(400, { form });
}
try {
    // Actual action: ...
} catch (error) {
    return fail(400, { form });
}

// Optional redirect: throw redirect(302, paths.register.thanks);

Imo, it would be super cool to have a function that abstracts all this stuff

@bbtgnn bbtgnn self-assigned this Jun 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant