You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Absolutely love zod, it's the first package I add to any TS project I'm working on.
I'm curious if zod has support / docs / examples of other projects that read schema types at runtime? Is depending on the internals of zod to do this a bad idea?
I'm the maintainer of the ERA relational algebra library. It ships with a runtime relational algebra type checker for type checking queries. I'd like to build a feature in ERA that roughly looks like this
class Relation {
/* .. */
compile<T extends z.ZodTypeAny>(zodSchema: T): () => Promise<z.infer<T>[]> {
// at runtime, the relation class runs ERA typechecker and knows the type of the
// output of this sql query. Lets say the query returns rows of the form `{ foo: string | null, bar: number }`
// I'd like to use `zodSchema` at runtime and make sure it can accept values of that form before
// actually running the query.
// Conceptual pseudo code
for (const zodField of zodSchema.something) {
assert(compatible(zodField, eraTypeCheck[zodField.name]))
}
}
}
Another way this could be accomplished is generating a zod schema from the era types and some sort of z.implementsOutputOf
schemaA.implementsOutputOf(schemaB)
The text was updated successfully, but these errors were encountered:
Hi!
Absolutely love zod, it's the first package I add to any TS project I'm working on.
I'm curious if zod has support / docs / examples of other projects that read schema types at runtime? Is depending on the internals of zod to do this a bad idea?
I'm the maintainer of the
ERA
relational algebra library. It ships with a runtime relational algebra type checker for type checking queries. I'd like to build a feature inERA
that roughly looks like thisAnother way this could be accomplished is generating a zod schema from the era types and some sort of
z.implementsOutputOf
The text was updated successfully, but these errors were encountered: