Skip to content
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

Retrieve the resolving schema from a ZodPromise #1838

Closed
bolencki13 opened this issue Jan 9, 2023 · 0 comments
Closed

Retrieve the resolving schema from a ZodPromise #1838

bolencki13 opened this issue Jan 9, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@bolencki13
Copy link
Contributor

bolencki13 commented Jan 9, 2023

Hey all -- I was playing around with ZodPromise and hoping to add this functionality in a PR. I checked out the CONTRIBUTING.md first and it asked I open an issue. So here I am....

ZodPromise is created with a second Zod type that is checked when the promise resolves. I'd like to be able to access the schema the ZodPromise was created with. For example

import { z } from 'zod';

const Foo = z.literal('foo')
const MyPromise = z.promise(Foo)

MyPromise.resolves() // should be a method that returns the Foo schema declared above

I'm not sure there is a way to do this at the moment and I'm open to suggestions on variable naming and such. If this is something that makes sense to PR I can draft something but looking for some feedback first. Thanks.

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

No branches or pull requests

2 participants