question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] TypeError: keyValidator._parse is not a function

See original GitHub issue

using separate zod schema doen’t work

🚀 ~ action ~ error TypeError: keyValidator._parse is not a function
    at ZodObject._parse (types.js:1188:37)
    at ZodObject._parseSync (types.js:109:29)
    at ZodObject.safeParse (types.js:139:29)
    at ZodObject.parse (types.js:120:29)
    at Object.parseForm (index.js:50:22)
    at async action (main.tsx:25:20)
    at async callLoaderOrAction (router.ts:2530:14)
    at async handleAction (router.ts:981:16)
    at async startNavigation (router.ts:904:26)
    at async Object.navigate (router.ts:784:12)

here the repo for reproduce: zodix-rr-reproduce

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
rileytomasekcommented, Nov 6, 2022

That makes sense because the dependency resolution would be less error prone that way.

Regardless, I just tested your repro with the v0.3.0 release and it’s working now.

0reactions
ZeevGcommented, Dec 5, 2022

I’m running into this issue in my project. Removing the following check seems to fix it

const finalSchema = schema instanceof ZodType ? schema : z.object(schema);

We’re using esbuild so it could be because of that. I haven’t dug in too deep but without esbuild it seems to work. It would be good to have a fix.

Edit: A suitable workaround (or maybe actually the intended way to use this library) is to pass a zod schema instead of a zod object.

eg from the docs

zx.parseParams(params, { id: z.string() })

instead of

zx.parseParams(params, z.object({ id: z.string() }))
Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: parse is not a function - node.js - Stack Overflow
I've checked my package.json file and have my start scripts assigned correctly. I have been at it with this error for nearly a...
Read more >
parse is not a function · Issue #155 · apollographql/graphql-tag
I'am getting error at query declaration. index.js:128 Uncaught TypeError: parse is not a function Debugging, I realized the method parse at ...
Read more >
How to fix this error? - Node - Code with Mosh Forum
TypeError : parse is not a function at Object. (C:\Users\pravi\Desktop\node\planets-project\index.js:8:11) ←[90m at Module.
Read more >
csv-parse - npm
CSV parser for Node.js and the web. Build Status NPM. The csv-parse package is a parser converting CSV text input into arrays or...
Read more >
Express body-parser middleware
If not a function, type option is passed directly to the type-is library and this can be an extension ... The parsing can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found