Support for schemas that is an enum of the keys of an object?
Essentially what I'm looking for would be something akin to this:
const Inputs = Z.object({
email: Z.string().email(),
password: Z.string().min(8),
username: Z.string().min(3),
id: Z.string().uuid(),
base: Z.unknown().optional(),
})
const InputFields: Z.ZodEnum<['email', 'password', 'username', 'id', 'base']> = Z.keyof(Inputs)
Is any form of the above currently possible, and if not, would anything bar its creation?
Hmmm.. Nothing comes to mind already. One tricky thing here is that you could have a schema like z.object({}).passthrough() which should make the keyof type never, which might be a little tricky.
I don't think there is anything impossible here, and PRs are welcome!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hello, i'm also in need for this feature. As i need to use an enum to validate user input based only on a provided schema for zodios library. Could you point to me where to start or check if i want to propose a Pull Request for this .
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.