#Use Form list with zod

9 messages Β· Page 1 of 1 (latest)

potent atlas
#

Can you use the zod schema with the use form list? Or does use form list only take a rules object?

modern topaz
potent atlas
#

zod is yelling at me when I try and do this

const schema = z.object({
    transfers: {
        email: z
        .string()
        .email({ message: "Invalid email" })
        .min(1, { message: "Email is required" }),
    }
});
#

because of the useFormList I have transfers

#

initialValues: {
transfers: formList([
{
email: "",
quantity: 0,
key: randomId(),
},
]),
},

#

basically the same question this person had #854810300876062773 message

modern topaz
median jolt
rare bay
#

maybe like
const schema = z.object({
transfers: z.array(z.object({
email: z
.string()
.email({ message: "Invalid email" })
.min(1, { message: "Email is required" }),
})),
});

πŸ˜‚