-
-
Notifications
You must be signed in to change notification settings - Fork 97
Open
Labels
adapterRelated to validation adaptersRelated to validation adaptersbugSomething isn't workingSomething isn't workingconfirmedConfirmed bug, will be worked upon in a near release.Confirmed bug, will be worked upon in a near release.
Description
When you have an object with dates and arrays, if the array fails validation, dates will be "".
V4 - Valid: false, Date:
V3 - Valid: false, Date: Sun Oct 01 2023 03:00:00 GMT+0300 (Eastern European Summer Time)
Failing test:
import { z as z4 } from 'zod/v4';
import { z as z3 } from 'zod/v3';
import { zod4, zod as zod3 } from 'sveltekit-superforms/adapters';
import { superValidate } from 'sveltekit-superforms';
export const load = async () => {
const data = {
date: new Date('2023-10-01T00:00:00Z'),
items: [{ id: 1, product: 'Product A' }, { id: 2, product: 'Product B' }, { id: 'bad' }]
};
// -------------------------------
const schema4 = z4.object({
date: z4.date(),
items: z4.array(
z4.object({
id: z4.number(),
product: z4.string()
})
)
});
const form4 = await superValidate(data, zod4(schema4), {
errors: false
});
console.log(V4 - Valid: ${form4.valid}, Date: ${form4.data.date});
// -------------------------------
const schema3 = z3.object({
date: z3.date(),
items: z3.array(
z3.object({
id: z3.number(),
product: z3.string()
})
)
});
const form3 = await superValidate(data, zod3(schema3), {
errors: false
});
console.log(V3 - Valid: ${form3.valid}, Date: ${form3.data.date});
};
Reported on Discord
Metadata
Metadata
Assignees
Labels
adapterRelated to validation adaptersRelated to validation adaptersbugSomething isn't workingSomething isn't workingconfirmedConfirmed bug, will be worked upon in a near release.Confirmed bug, will be worked upon in a near release.