Skip to content

Commit 1c4c9e7

Browse files
authored
Merge pull request #4 from glideapps/zod4
Switch to Zod4
2 parents 254d67e + 5958ea2 commit 1c4c9e7

File tree

13 files changed

+475
-633
lines changed

13 files changed

+475
-633
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ dist
55
coverage
66
.nyc_output
77
.vscode
8+
.claude/settings.local.json

CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
1515

1616
## Code Style
1717
- **TypeScript**: Use strict types with proper JSON Schema interface typing
18-
- **Imports**: Use named imports (`import { z } from "zod"`)
18+
- **Imports**: Use named imports (`import { z } from "zod/v4"`)
1919
- **Formatting**: 4-space indentation, prefer lines under 80 chars
2020
- **Functions**: Pure functions with no side effects, descriptive names in camelCase
2121
- **Types/Interfaces**: Use PascalCase, export types used in public API
@@ -30,4 +30,4 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
3030
- Use esbuild for bundling with optimized output
3131
- Follow semantic versioning for releases
3232

33-
For release process, see RELEASE.md
33+
For release process, see RELEASE.md

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ A library that creates [Zod](https://github.com/colinhacks/zod) types from [JSON
1111
npm install zod-from-json-schema
1212
```
1313

14+
## Zod 3 vs 4
15+
16+
- If you need Zod 4, use the latest version of this package.
17+
- If you need Zod 3, use the latest version that's less than 0.4.0 (at the of writing that's 0.0.5)
18+
1419
## Usage
1520

1621
This package supports both ESM and CommonJS formats.
@@ -96,7 +101,7 @@ Converts a JSON Schema object to a complete Zod schema.
96101

97102
- **Parameters**:
98103
- `schema` (Object): A JSON Schema object
99-
- **Returns**:
104+
- **Returns**:
100105
- A Zod schema that validates according to the JSON Schema
101106

102107
### `jsonSchemaObjectToZodRawShape(schema)`
@@ -105,7 +110,7 @@ Extracts the object properties from a JSON Schema object into a Zod raw shape. T
105110

106111
- **Parameters**:
107112
- `schema` (Object): A JSON Schema object that should have a `properties` field
108-
- **Returns**:
113+
- **Returns**:
109114
- A `ZodRawShape` object that can be used with `z.object()`
110115

111116
**Example**:

examples/cjs-example.js

Lines changed: 0 additions & 40 deletions
This file was deleted.

examples/esm-example.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

examples/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
"private": true,
44
"type": "module",
55
"scripts": {
6-
"cjs": "node cjs-example.js",
7-
"esm": "node esm-example.js"
6+
"cjs": "node cjs-example.cjs",
7+
"esm": "node esm-example.mjs"
88
},
99
"dependencies": {
10-
"zod": "^3.24.2",
10+
"zod": "^3.25.25",
1111
"zod-from-json-schema": "file:.."
1212
}
13-
}
13+
}

package-lock.json

Lines changed: 58 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zod-from-json-schema",
3-
"version": "0.0.5",
3+
"version": "0.4.0",
44
"description": "Creates Zod types from JSON Schema at runtime",
55
"main": "dist/index.js",
66
"module": "dist/index.mjs",
@@ -30,14 +30,13 @@
3030
"url": "git+https://github.com/glideapps/zod-from-json-schema.git"
3131
},
3232
"dependencies": {
33-
"zod": "^3.24.2"
33+
"zod": "^3.25.25"
3434
},
3535
"devDependencies": {
3636
"@vitest/coverage-v8": "^3.0.9",
3737
"esbuild": "^0.25.2",
38-
"typescript": "^5.8.2",
39-
"vitest": "^3.0.9",
40-
"zod-to-json-schema": "^3.24.5"
38+
"typescript": "^5.8.3",
39+
"vitest": "^3.0.9"
4140
},
4241
"keywords": [
4342
"zod",

0 commit comments

Comments
 (0)