dannyeloD
Convex Community2y ago
3 replies
dannyelo

Zod and Convex type error

Hello,
I'm using Zod to validate my forms.
When I pass the form data to a mutation function, I got a type error.
The function expect some convex ids and the zod schema is a simple string.
What is the fix here?

Zod Schema
const OrderFormSchema = z.object({
  salesChannelId: z.string(),
  customerId: z.string(),
  status: z.string(),
  ...
})


Expecting
args: {
  salesChannelId: v.id('sales_channels'),
  customerId: v.id('customers'),
  status: v.string(),
  ...
},


Error
Types of property 'customerId' are incompatible.
    Type 'string' is not assignable to type 'Id<"customers">'.
Was this page helpful?