anmot.A
Convex Community•2y ago•
4 replies
anmot.

Can we use zodToConvex with defineEnt when defining ent schema?

Below is the error

TS error:
Argument of type 'ObjectValidator<{ name: Validator<string, false, never>; }>' is not assignable to parameter of type 'Record<string, Validator<any, any, any>>'.
  Index signature for type 'string' is missing in type 'Validator<{ name: string; }, false, "name">'.t


npx convex dev error:
 InvalidSchema: Hit an error while evaluating your schema:
Invalid validator for key `json`: Not a field validator


Here is the schema

const schema = defineEntSchema({
  users: defineEnt({
    name: v.string(),
  })
    .edges("messages", { ref: true }),
  messages: defineEnt({
    text: v.string()
  })
    .edge("user"),
  tags: defineEnt(zodToConvex(z.object({
    name: z.string(),
  }))),
});
Was this page helpful?