Repository navigation
Will addIssue be deprecated for superRefine ctx variable? #6717
Replies: 2 comments
|
Hi @MasterOdin! I'm Dosu, a bot trained on Zod's codebase & issues, and I'm helping the Zod team.
The changelog entry applies specifically to So there's no need to change your example on account of that changelog entry. I can't confirm future deprecation plans; @colinhacks would need to speak to those. Feel free to close the discussion if that answers your question. To reply, just mention @dosu. Docs are dead. Just use Dosu. |
|
The deprecation in the v4 changelog is only about the methods on Some context that might help you decide what to write going forward:
z.array(z.string()).superRefine((val, ctx) => {
if (val.length !== new Set(val).size) {
ctx.issues.push({ code: "custom", message: "No duplicates allowed.", input: val });
}
});
z.array(z.string()).check((ctx) => {
if (ctx.value.length !== new Set(ctx.value).size) {
ctx.issues.push({ code: "custom", message: "No duplicates allowed.", input: ctx.value });
}
});Only Colin can speak to long-term plans, but as of today |
Uh oh!
There was an error while loading. Please reload this page.
From the docs for
superRefine:It uses the
.addIssuefunction to add the issue. Doing a similar thing was deprecated for errors, will a similar thing happen for the ctx variable?All reactions