Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant