[zfd] How to have a generic function accepting a zod-form-data object? #247
Unanswered
CapitaineToinon
asked this question in
Q&A
Replies: 1 comment
-
Hi! I'm not sure I fully understand what you're trying to do here. Could you give a more concrete description of your use-case? Whatever the solution ends up being, you most likely will want to leave more up to inference and use fewer explicit types. Without more info, here are a couple examples of how you might wrap a formData schema: Playground link |
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
-
Using [email protected], how can I have a function expecting a zod-form-data object that is generic? Here is some code sample of what I'm trying to do.
Here is some code example:
https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgLzgXzgMyhEcDkyEAJvgFCiSyIqbHpY56EkC0m0IrxAhjD+TIBjCADsAzvHFCAFgFMQPOAF5axAHQcoIACJ8eACgRk4puAp7AANgC416mHIAeMAwEoANGTRuyZTACuokIwwGJwfI7gMACMADwAKuYucqLE4ijqAIKiAJ4AWiQA8gBGAFZyIQB8BtLyinYASnIwAVCiCblgcnEwXXIQmPZauvpVbnbI6sCimHJQvf2DcHUWVYgmZgD0W3AwMsAZAO7QANYZJQFSshZwh3CiEEdwy33dmYXEAKKYcyHicSmn063RyuQ8ETyEIAYpw9PwADLAU5yACSojAVyqm1MOzgqLgQh4onw8DAPHEGSSMxgED28j2-Tg8igchWdMiCjAsTuGUe8AA5ql5sAhDi4HiTgErPQrBAAG5s8S4FoHUQCuBWZFs5qtdognpvAZDZB0TRw-SJKrrRS5EpyAD84rxRSgyUg4jZsO08J4BoiGSFohFQnZ+MJEGl9GIdNWDTg3tG-ANVqdaD8Igk8CUqk50RitRuijcAG4JbsTlBznBLtneZDcmQ8ZnJBE7MTG03dgBNbXiMhGhMWxHa9GY+CqXVtDr9RbdZamjQjX3rZyONIZIEkH5-GAArfEA1giEdiEzOZugCq6wdcEvcDswcVUD8gWCoXCee5ACZEsl1+kmRgp8pQVNUhb1DwkzqJ8O6VHuiQQlMkYwOOVowsOPBIiiY5YhMmTnvMc7GisRY8OsxhmHArJ6qIpGQeo5JQJ6BgAETyLkrG+OmwhiK2JQqBEMBRD+EEWG45ZwJW1bEvQ9xBiGACEXYRlmNZ2EgFjWHYkhQDMGpoEAA
Doing this because I'm trying to restrict the zod-form-data object to contain a AnyZodObject and not a ZodTypeAny so I can access the inner shape of the formData. Basically the first signature from this type from zod-form-data:
I'm open to other ways I could do things. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions