Skip to content

Commit ed19146

Browse files
authored
Add z.function() to the list of JSON incompatible schemas (#2971)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * JSON compatibility checks now flag functions as unsupported, improving detection in deep and circular schemas. * **Tests** * Updated tests to cover function handling in circular type scenarios. * **Documentation** * Changelog updated (v25.5.2) noting that functions are now treated as JSON-incompatible and will warn when used in JSON-focused endpoints. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 975eaa5 commit ed19146

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Version 25
44

5+
### v25.5.2
6+
7+
- Added `z.function()` to the list of JSON-incompatible schemas:
8+
- It will warn when using such schema in a JSON operating Endpoint;
9+
- `z.function()` [became a schema again](https://github.com/colinhacks/zod/issues/4143) in Zod 4.1.0.
10+
511
### v25.5.1
612

713
- Aligned the requirements on Node.js versions between for `@express-zod-api/zod-plugin`;

express-zod-api/src/deep-checks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const unsupported: FirstPartyKind[] = [
7373
"void",
7474
"promise",
7575
"never",
76+
"function",
7677
];
7778

7879
export const findJsonIncompatible = (

express-zod-api/tests/routing.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ describe("Routing", () => {
511511
});
512512
});
513513

514-
const circular: z.ZodType = z.lazy(() => z.tuple([circular, z.nan()]));
514+
const circular: z.ZodType = z.lazy(() => z.tuple([circular, z.function()]));
515515
test.each([
516516
[z.bigint(), z.set(z.string())],
517517
[z.nan(), z.map(z.string(), z.boolean())],

0 commit comments

Comments
 (0)