-
Hi everyone, hope all is well. I wondered if there was a method to check if something was a zod schema. I'm working with a complex signature right now for something and a value I have could be one of three things, a schema, a function argument or a zod schema. I was looking for something like What would be the best way to do this? |
Beta Was this translation helpful? Give feedback.
Answered by
digimuza
Oct 25, 2021
Replies: 1 comment 2 replies
-
You can easily check z.ZodType is base class for all zod schemas so you easily can do const schema = z.object({})
if (schema instanceof z.ZodType) {
// this is zod type
} If you want more specific checks if (schema instanceof z.ZodObject) {
// this is zod object type
} |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
alii
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
You can easily check
z.ZodType is base class for all zod schemas so you easily can do
If you want more specific checks