Statically typing schema #1410
Answered
by
nullndr
haldunanil
asked this question in
Q&A
-
Hi, apologies if this has already been asked/answered or if it's in the readme, but is there a way to assert that a schema adheres to a desired shape rather than inferring the shape from a schema? For example, I want to do: interface MyType {
id: string;
}
const schema: <something that uses MyType> = z.object({
id: z.string()
});
// -> passes
const schema: <something that uses MyType> = z.object({
id: z.string(),
inventory: z.number(),
});
// -> fails is there something i can put instead of |
Beta Was this translation helpful? Give feedback.
Answered by
nullndr
Sep 19, 2022
Replies: 1 comment
-
Yes, check |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
haldunanil
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, check
toZod