Skip to content

Commit 03cfb4a

Browse files
committed
refactor: use instanceof ValidationError instead of duck-typing
Replace duck-typed check `if(error.error?.valueError)` with explicit type check `if(error.error instanceof ValidationError && error.error.valueError)` to ensure only true ValidationError instances are handled.
1 parent 9fa92b5 commit 03cfb4a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/compose.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ const coerceTransformDecodeError = (
460460
`c.set.status=422\n` +
461461
// Fix #1660: When error.error is a ValidationError with wrong 'type' field,
462462
// extract valueError and fix its path using TransformDecodeError.path
463-
`if(error.error?.valueError){` +
463+
`if(error.error instanceof ValidationError && error.error.valueError){` +
464464
`const ve=error.error.valueError;` +
465465
`const fe={...ve,path:error.path};` +
466466
`const errs={[Symbol.iterator]:function*(){yield fe},First:()=>fe};` +

0 commit comments

Comments
 (0)