Skip to content

[2.59.0] Cannot submit form with unchecked checkbox #15785

Description

@henrykrinkle01

Describe the bug

When a form has an unchecked checkbox, and the checkbox schema is defined with z.coerce.boolean() (like suggested by the docs), the form can not be submitted. It stops working when I upgrade kit to 2.59.0.

Reproduction

import { form} from '$app/server';
import z from 'zod';

const schema = z.object({
  canSubmitUnchecked: z.boolean().optional().transform((v) => v ?? false),
  cannotSubmitUnchecked: z.coerce.boolean<boolean>(),
});

export const testForm = form(schema, async (data) => {
  console.log(data);
});

https://stackblitz.com/edit/ji42wvw5?file=src%2Froutes%2F%2Bpage.svelte,src%2Froutes%2Ftest.remote.ts

Logs

System Info

svelte@5.55.5
kit@2.59.0

Severity

serious, but I can work around it

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions