How can I add z.record(z.any()) to z.object()? #1159
dolfandringa
started this conversation in
General
Replies: 1 comment
-
Lol, as usual, after trying everything and forcing myself to write the question down, I realize there is one thing I didn't try yet: catchall
last line resulting in
The |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I want to create a schema equivalent to this type definition:
Which could be successfully used as type for
{a: 1}
and{a: 1, b: 'test', c:{ d: 'e'}}
but not{b: 'test'}
. I have seenz.record(z.any())
, but I can't find a way to use it in an object to get the type definition above. I have triedwhich results in
and
resulting in
and
which doesn't result in an error but should.
How can I achieve this?
Cheers
Beta Was this translation helpful? Give feedback.
All reactions