Coerce input type

3 Replies
Scott Trinh
Scott Trinh3y ago
Yeah, coerce doesn't work that way since it doesn't know what you're coercing from. If you care about the input type and can deal with ZodEffect, I would suggest avoid coerce and using a more precise input type with transform. I think in your use case (URLSearchParams), I would just not care about the input type since they'll be string | string[] and you won't be constructing them manually I assume.
Unknown User
Unknown UserOP3y ago
Message Not Public
Sign In & Join Server To View
Scott Trinh
Scott Trinh3y ago
The valid types of coerce is really unknown to allow attempting to coerce from any other type (think number to Date, etc)

Did you find this page helpful?