8000 [V4] Error when using z.record() · Issue #4338 · colinhacks/zod · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[V4] Error when using z.record() #4338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bakura10 opened this issue May 8, 2025 · 0 comments
Open

[V4] Error when using z.record() #4338

bakura10 opened this issue May 8, 2025 · 0 comments

Comments

@bakura10
Copy link
bakura10 commented May 8, 2025

Hello,

I am trying to create a schema that validates a set of pre-defined keys, and also accept any other keys that starts by the word custom (any other keys that are not part of the schema or do not start with custom should simply be ignored). From what I've found, and due to merge deprecation, this is how it is supports to work:

const schema = z.object(
  title: z.string(), // fixed schema
  ...z.record(z.string().startsWith('custom'), z.any())
});

Unfortunately, upon validation I have this rather cryptic error:

Image

Is this a bug of the V4?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0