Skip to content

boolean default value set to true in schema defaults to false when validating URL #633

@OTheNonE

Description

@OTheNonE
  • Before posting an issue, read the FAQ and search the previous issues.

Description
Basically the title of the issue:

const formSchema = z.object({
    "orderby": z.boolean().default(true), // Set default value of `orderby` to `true`
});

const url = new URL("http://test.com") // create an `URL` with no `searchParams` set.

const form = await superValidate(url, zod(formSchema)) // URL validation.

console.log(form.data.orderby) // returns `false`

MRE:
https://www.sveltelab.dev/ivgtl6o005nlof3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdoneIssue is fixed, will most likely be included in the next release.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions