Skip to content

feat(zod)!: upgrade to Zod v4, remove zod-to-json-schema - #3482

Closed
MuntasirSZN wants to merge 22 commits into
nuxt:mainfrom
MuntasirSZN:main
Closed

feat(zod)!: upgrade to Zod v4, remove zod-to-json-schema#3482
MuntasirSZN wants to merge 22 commits into
nuxt:mainfrom
MuntasirSZN:main

Conversation

@MuntasirSZN

@MuntasirSZNMuntasirSZN commented Jul 26, 2025

Copy link
Copy Markdown

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Upgrades from Zod v3 to v4 using native toJSONSchema() method, replacing the zod-to-json-schema dependency. toJsonSchema doesn't support dates, so had to go through that.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@vercel

vercelBot commented Jul 26, 2025

Copy link
Copy Markdown

@MuntasirSZN is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

@MuntasirSZN

Copy link
Copy Markdown
Author

Maybe this should be a breaking change?

@pkg-pr-new

pkg-pr-newBot commented Jul 26, 2025

Copy link
Copy Markdown
npm i https://pkg.pr.new/@nuxt/content@3482

commit: 3879b0f

- Replace complex post-processing with Zod v4's built-in override
callback
- Use target: 'draft-7' for proper nullable handling (anyOf instead of
oneOf)
- Handle dates with override callback for {type: "string", format:
"date-time"}
- Reduce implementation from ~100 lines to ~20 lines of processing
- Fix import paths from 'zod/v4/core' to 'zod/v4' across codebase
@farnabaz

Copy link
Copy Markdown
Member

Thanks for the PR @MuntasirSZN
Indeed this will be a breaking change, what I like to do it use this opportunity to make Zod an optional dependency and allow users to use their preferred validation library. I'm thinking of introducing small helpers to make it possible.

Meanwhile I'll keep it PR pending so users can user Zod4 with PR release

npm i https://pkg.pr.new/@nuxt/content@3482

@MuntasirSZN

Copy link
Copy Markdown
Author

@farnabaz what about Standard Schema? I am happy to implement that.

@MuntasirSZNMuntasirSZN changed the title feat(zod): upgrade to Zod v4, remove zod-to-json-schemafeat(zod)!: upgrade to Zod v4, remove zod-to-json-schemaAug 4, 2025
@farnabaz

Copy link
Copy Markdown
Member

@farnabaz what about Standard Schema? I am happy to implement that.

AFAIK, The issue with standard schema is it does not expose schema and only expose unified validation. But I would be happy to see Standard Schema working in Nuxt Content

Norbiros added a commit to Hack4Krak/Hack4KrakSite that referenced this pull request Aug 16, 2025
We need nuxt/content#3482, to
resolve some very interesting issues while running vitest
on GitHub actions.
@Norbiros

Copy link
Copy Markdown

Maybe for now a compatibility layer could be added to fix #3462 without fully updating to zod v4?

Norbiros added a commit to Hack4Krak/Hack4KrakSite that referenced this pull request Aug 16, 2025
We need nuxt/content#3482, to
resolve some very interesting issues while running vitest
on GitHub actions.
test: add raw zod toJSONSchema passthrough tests (editor meta, nullable anyOf, union anyOf, intersection allOf)
chore: satisfy eslint for zod editor augmentation and tests
chore: lint and fix
chore: fix typo
@MuntasirSZN

Copy link
Copy Markdown
Author

Checkout #3524

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot start nuxt: Cannot read properties of undefined (reading 'id')

3 participants

@MuntasirSZN@farnabaz@Norbiros