Zod error about intermediate value when submitting form

I'm getting the following error when tryign to submit a simple form using zod and react-hook-form.
zod.mjs:7 Uncaught (in promise) TypeError: o[(intermediate value)(intermediate value)(intermediate value)] is not a function
zod.mjs:7 Uncaught (in promise) TypeError: o[(intermediate value)(intermediate value)(intermediate value)] is not a function
export const BankAccountFormSchema = z.object({
name: z.string().min(1, "account name is required"),
bankName: z.string().min(1, "bank name is required"),
cardProvider: z.nativeEnum(CardProvider).nullable(),
cardType: z.nativeEnum(CardType).nullable(),
cardholderName: z.string().min(1, "cardholder name is required"),
style: z.nativeEnum(BankAccountStyle).default(BankAccountStyle.DEFAULT),
theme: z
.string()
.regex(/^#[0-9A-Fa-f]{6}$/, "must be a valid hex color")
.default("#333333"),
textColor: z
.string()
.regex(/^#[0-9A-Fa-f]{6}$/, "must be a valid hex color")
.default("#FFFFFF"),
});
export const BankAccountFormSchema = z.object({
name: z.string().min(1, "account name is required"),
bankName: z.string().min(1, "bank name is required"),
cardProvider: z.nativeEnum(CardProvider).nullable(),
cardType: z.nativeEnum(CardType).nullable(),
cardholderName: z.string().min(1, "cardholder name is required"),
style: z.nativeEnum(BankAccountStyle).default(BankAccountStyle.DEFAULT),
theme: z
.string()
.regex(/^#[0-9A-Fa-f]{6}$/, "must be a valid hex color")
.default("#333333"),
textColor: z
.string()
.regex(/^#[0-9A-Fa-f]{6}$/, "must be a valid hex color")
.default("#FFFFFF"),
});
const form = useForm({
resolver: zodResolver(BankAccountFormSchema),
defaultValues: {
name: "",
bankName: "",
cardProvider: null,
cardType: null,
cardholderName: "",
style: BankAccountStyle.DEFAULT,
theme: "#333333",
textColor: "#FFFFFF",
},
});
const form = useForm({
resolver: zodResolver(BankAccountFormSchema),
defaultValues: {
name: "",
bankName: "",
cardProvider: null,
cardType: null,
cardholderName: "",
style: BankAccountStyle.DEFAULT,
theme: "#333333",
textColor: "#FFFFFF",
},
});
No description
1 Reply
zaini
zainiOP2d ago
"zod": "^3.24.3", "react-hook-form": "^7.56.1", FIXED the issue is that the zod schema i was importing was in a "use server" file - moved it to a regular file instead

Did you find this page helpful?