-
-
Notifications
You must be signed in to change notification settings - Fork 99
Open
Labels
bugSomething isn't workingSomething isn't workingdoneIssue is fixed, will most likely be included in the next release.Issue is fixed, will most likely be included in the next release.
Description
Description
When defining a nested schema with, which includes dates, and the default values for those dates are set on the parent object, the default values are strings instead dates.
This is a regression compared to zod v3
export const schema = z.object({
name: z.string().min(2),
email: z.email(),
dateRange: z.object({
start: z.date(),
end: z.date()
}).default({
start: new Date(),
end: new Date()
}),
dateRangeIndividual: z.object({
start: z.date().default(new Date()),
end: z.date().default(new Date())
}),
date: z.date().default(new Date())
});Resulting $form object values:
{
name: "",
email: "",
dateRange: {
start: "2025-10-29T10:47:03.068Z", // <- string
end: "2025-10-29T10:47:03.068Z" // <- string
},
dateRangeIndividual: {
start: 2025-10-29T10:52:25.537Z, // <- date
end: 2025-10-29T10:52:25.537Z // <- date
},
date: 2025-10-29T10:47:03.068Z // <- date
}
If applicable, a MRE
https://www.sveltelab.dev/kata9i0q30dg6vk?files=.%2Fsrc%2Froutes%2Fschema.ts
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingdoneIssue is fixed, will most likely be included in the next release.Issue is fixed, will most likely be included in the next release.