Skip to content

Problems migrating to v1 #515

Answered by edmundhung
Apsysikal asked this question in Q&A
Discussion options

You must be logged in to vote

Sorry for the confusion. The intent is considered null now on submit as you are likely submitting through a button with no explicit name / value pair describing the intent.

So I would imagine the equivalent implementation on v1 would be:

const submission = await parse(formData, {
    schema: (intent) =>
      schema.transform(async (data, ctx) => {
        if (intent !== null) return { ...data, user: null };
        const user = await verifyLogin(data.email, data.password);
        if (!user) {
          ctx.addIssue({
            path: ["password"],
            code: z.ZodIssueCode.custom,
            message: "Invalid username or password",
          });
          return z.NEVER;
        }

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Apsysikal
Comment options

Answer selected by Apsysikal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants