Cannot read property '_parse' of undefined #948
-
Hi, I have a Zod object like this const zodObj = z.object( { id: string } ) then I extend it by const extendObj = zodObj.pick( { wrongKey: true, id: true } ) when I run extendObj.parse( { id: "xxx" } ) I will get error
This can be fixed by remote |
Beta Was this translation helpful? Give feedback.
Answered by
JacobWeisenburger
Feb 20, 2022
Replies: 1 comment
-
You need to use const zodObj = z.object( { id: z.string() } )
const extendObj = zodObj.extend( { wrongKey: z.any() } )
console.log( extendObj.parse( { id: 'xxx' } ) ) // { id: 'xxx' } |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
JacobWeisenburger
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to use
.extend()
, not.pick()
.