Skip to content

Commit 83e8ea4

Browse files
committed
early return on own issues
1 parent 2e7ab71 commit 83e8ea4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

deno/lib/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4264,8 +4264,10 @@ export class ZodEffects<
42644264

42654265
const effect = this._def.effect || null;
42664266

4267+
let hasIssue = false;
42674268
const checkCtx: RefinementCtx = {
42684269
addIssue: (arg: IssueData) => {
4270+
hasIssue = true;
42694271
addIssueToContext(ctx, arg);
42704272
if (arg.fatal) {
42714273
status.abort();
@@ -4282,7 +4284,7 @@ export class ZodEffects<
42824284

42834285
if (effect.type === "preprocess") {
42844286
const processed = effect.transform(ctx.data, checkCtx);
4285-
if (ctx.common.issues.length) {
4287+
if (hasIssue) {
42864288
return {
42874289
status: "dirty",
42884290
value: ctx.data,

src/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4264,8 +4264,10 @@ export class ZodEffects<
42644264

42654265
const effect = this._def.effect || null;
42664266

4267+
let hasIssue = false;
42674268
const checkCtx: RefinementCtx = {
42684269
addIssue: (arg: IssueData) => {
4270+
hasIssue = true;
42694271
addIssueToContext(ctx, arg);
42704272
if (arg.fatal) {
42714273
status.abort();
@@ -4282,7 +4284,7 @@ export class ZodEffects<
42824284

42834285
if (effect.type === "preprocess") {
42844286
const processed = effect.transform(ctx.data, checkCtx);
4285-
if (ctx.common.issues.length) {
4287+
if (hasIssue) {
42864288
return {
42874289
status: "dirty",
42884290
value: ctx.data,

0 commit comments

Comments
 (0)