anmot.
anmot.ā€¢7mo ago

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
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
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(),
}))),
});
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(),
}))),
});
4 Replies
Michal Srb
Michal Srbā€¢7mo ago
I think the upcoming Convex release might fix this issue, as both the zod helpers and Ents are getting a revamp. @sshader has been working on this.
anmot.
anmot.OPā€¢7mo ago
Any rough ETA on when the next release would be? Right now Iā€™m evaluating whether to continue with convex vanilla API or wait for the fix in ents.
Michal Srb
Michal Srbā€¢7mo ago
I think it'll be early next week (but reserve the right to be wrong šŸ™‚ ).
anmot.
anmot.OPā€¢7mo ago
Awesome. I will wait for it then. Thanks for your help.

Did you find this page helpful?