You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am going through the Tutorial of the CRUD example here
It has this code passage:
import { superValidate, message } from 'sveltekit-superforms';
import { zod } from 'sveltekit-superforms/adapters';
import { error, fail, redirect } from '@sveltejs/kit';
import { users, userId } from '$lib/users';
export const load = async ({ url, params }) => {
// READ user
const user = users.find((u) => u.id == params.id);
if (params.id && !user) throw error(404, 'User not found.');
// If user is null, default values for the schema will be returned.
const form = await superValidate(user, zod(crudSchema));
return { form, users };
};
What is confusing to me is this comment: // If user is null, default values for the schema will be returned.
It is not true, because when the user is null we throw an error in the line above and so we won't return an object with the default values.
How does this work?
The text was updated successfully, but these errors were encountered:
I am going through the Tutorial of the CRUD example here
It has this code passage:
What is confusing to me is this comment:
// If user is null, default values for the schema will be returned.
It is not true, because when the user is null we throw an error in the line above and so we won't return an object with the default values.
How does this work?
The text was updated successfully, but these errors were encountered: