v4: `parse` and `safeParse` no longer accept `path` in params
This was helpful when validating some specific deeply-nested properties inside an object without worrying about manually altering the path in the root and union issues for it to be a valid path relative to the root object and just simply handling issues as-is.
Here's the ParseParams interface in v3 used by parse and safeParse:
https://github.com/colinhacks/zod/blob/8cca93b7cc3f8c5fa17303bbb82d5c531ec24f33/src/helpers/parseUtil.ts#L43-L47
I couldn't find any mentions of this change in the migration guide so I assume it was unintentional.
Also, path is no longer available inside transforms and refinements' ctx, which was crucial for recursive types to make validations based on the current path. Notify me if I should create a separate issue for this.
I'm afraid these are both intentional and known changes in Zod 4.
The top-level path param in the parse methods was just a mistake. That was intended as an internal field.
As for ctx.path, I've added the following to the changelog:
Your use case with recursive types is interesting, but the ctx.path information just isn't available anymore with Zod's new parsing architecture. Path arrays are constructed lazily only after a validation error is encountered.