zod
zod copied to clipboard
Reporting errors of the preprocess that is the second property of object
Fix https://github.com/colinhacks/zod/issues/2904
This behavior was introduced in #2426. ctx.common.issues includes the errors of previous properties, so that they affects the status of preprocess.
Deploy Preview for guileless-rolypoly-866f8a ready!
| Name | Link |
|---|---|
| Latest commit | 152bfdb796ff89594a0177bd4697785f19c3e817 |
| Latest deploy log | https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/65fc90d2ad067c0008589605 |
| Deploy Preview | https://deploy-preview-2912--guileless-rolypoly-866f8a.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
I'm not confident in my understanding of the whole codebase and the change in #2426.
@Pingviinituutti Could you take a look at this PR?
Looks good to me, seems the simple fix is enough to :)
Are the current test cases enough to ensure it works as intended?
@Pingviinituutti Thanks!
Are the current test cases enough to ensure it works as intended?
The current test cases are fail on master branch, so I think it's minimum but enough.
Is there any movement on this? This is causing major issues for us.
@Austin-Love This is ready and waiting for getting review
Great stuff @yukukotani and apologies to everyone who waited so long for this.
I made some fairly major changes to ctx.addIssue in preprocess, so it behaved identically to .superRefine and .transform. Namely, all issues are considered non-fatal — validation will continue even if .addIssue was called during the preprocess. This behavior can be modified by indicating fatal: true in ctx.addIssue:
const schema = z.preprocess((data, ctx) => {
ctx.addIssue({
code: "custom",
message: `bad thing happened`,
fatal: true
});
return data;
}, z.string())