We have a project where we are using yup
and now zod
for validation, in parallel. We need a way to reliably distinguish one schema from another. Are there any methods in either of these to detect this? Something like: yup.isYupSchema()
or z.isZodSchema()
?
Asked
Active
Viewed 182 times
0

jayarjo
- 16,124
- 24
- 94
- 138
1 Answers
0
Let's say this is a schema that you have:
const zodSchema = z.object({
one: z.number(),
two: z.object({
three: z.number(),
four: z.number(),
}),
});
Then you can check whether this is indeed a zod
schema by running:
import { ZodObject } from 'zod';
zodSchema instanceof ZodObject

jayarjo
- 16,124
- 24
- 94
- 138