colinhacks/zod

Is `z.effect()` safe to use?

Closed this issue · 2 comments

lpww commented

First of all, thanks for this great validation library! I'm hoping to get some guidance from the maintainers around the use of z.effect.

It has been mentioned in some issues as a way to perform preprocessing. However, it's not officially documented. Is this API intended for public use?

#2486
#2942

There's nothing z.effect can do that isn't already expressible with either z.preprocess() and .transform() APIs. While it is part of the public API, there's really no reason to use it, which is why I didn't document it. Note also that there will likely be breaking changes to z.effect in Zod 4 (the upcoming new major version), whereas the other two are more likely to be backwards-compatible.

lpww commented