hinogi - tsconst a = z.object({ foo: z.strin...
this will error because
foo
is undefined. What do I need to change here to make a
optional so that it will not break if bar
is just empty since foo should be optional?Solution:Jump to solution
ok so foo has to be foo: null | undefined and {} is not a valid solutions. also, if null, the key will persist, if undefined the key is gone 😄 thanks playground
6 Replies
bit additional background, such a thing is generated by graphql codegen schema validation, I try to figure out how to fix this for optional input types depending on non nullable input properties
Unknown User•7d ago
Message Not Public
Sign In & Join Server To View
sure
but I am not sure if it needs to be
or something
Zod Playground
An interactive playground for testing and learning Zod schemas
Solution
ok so foo has to be foo: null | undefined and {} is not a valid solutions. also, if null, the key will persist, if undefined the key is gone 😄 thanks playground
