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
First of all: thanks for great contribution to this package, it's really awesome.
However, I ran into an issue when I try to validate a union of objects, which simply looks like this:
constextensions=z.object({name: z.string(),})constdog=z.object({
extensions
});constcat=z.object({
extensions
});constanimal=z.union([dog,cat]);// it should output type error because name is ought to be type of stringconstvalidateResult=animal.parse({extensions: {name: 123}});
And I expected the validateResult to contain errors but instead it didn't.
And when I changed the code to:
- const extensions = z.object({- name: z.string(),- })
const dog = z.object(
- extensions+ extensions: z.object({+ name: z.string(),+ })
});
const cat = z.object({
- extensions+ extensions: z.object({+ name: z.string(),+ })
});
const animal = z.union([dog, cat]);
// it should output type error because name is ought to be type of string
const validateResult = animal.parse({ extensions: { name: 123 } });
It surprisingly worked!!
Really need your help. Appreciate it!
The text was updated successfully, but these errors were encountered:
First of all: thanks for great contribution to this package, it's really awesome.
However, I ran into an issue when I try to validate a union of objects, which simply looks like this:
And I expected the
validateResult
to contain errors but instead it didn't.And when I changed the code to:
It surprisingly worked!!
Really need your help. Appreciate it!
The text was updated successfully, but these errors were encountered: