p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

Update zod 3 to zod 4 support in p5.js dev-2.0

Open madhav2348 opened this issue 6 months ago • 4 comments

Resolves #7833

Changes:

  • line 325 schema items can be accessed within def
  • line 356 and 360 _def is deprecated, use def or directly use options
  • line 393 zodErrorObj.errors[0] changes to zodErrorObj.issues[0]
  • line 410 union error changes to errors
  • line 414 and 459, received changes to message
  • Test cases are updated. According to zod 4, error messages are elaborated

Important

constant.js have some variable which are Symbols , according to zod 4, Symbols aren't considered literal values, nor can they be simply compared with ===. This was an oversight in Zod 3.

PR Checklist

madhav2348 avatar Jun 04 '25 04:06 madhav2348

🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already. And be sure to add yourself to the list of contributors on the readme page!

welcome[bot] avatar Jun 04 '25 04:06 welcome[bot]

Hi @madhav2348 ! Thanks for working on this. From the tests, looks like the zod update in package.json itself isn't part of the PR?

ksen0 avatar Jun 04 '25 19:06 ksen0

Hi @madhav2348 ! Thanks for working on this. From the tests, looks like the zod update in package.json itself isn't part of the PR?

My apologies, Thank you for figuring out. I was trying to reproduce the failed test case by switching back and forth between Zod 3 and Zod 4 versions to confirm which leads to uncommitted package.json changes.

madhav2348 avatar Jun 04 '25 19:06 madhav2348

Thanks for taking this on! Are the changed property names and error types due to the originals no longer existing in zod 4? Just for my own understanding, did you come across any docs explaining those differences?

I went through the migration docs, but they haven't covered all the changes. The changes I made are by going through the source code of Zod 4. Please let me know if further adjustments are needed!

Thank you

madhav2348 avatar Jun 06 '25 11:06 madhav2348

Thanks for your patience on this @madhav2348, I think this is good to go!

davepagurek avatar Jun 29 '25 16:06 davepagurek

@all-contributors please add @madhav2348 for code

davepagurek avatar Jun 29 '25 16:06 davepagurek

@davepagurek

I've put up a pull request to add @madhav2348! :tada:

allcontributors[bot] avatar Jun 29 '25 16:06 allcontributors[bot]