Update zod 3 to zod 4 support in p5.js dev-2.0
Resolves #7833
Changes:
- line 325 schema
itemscan be accessed withindef - line 356 and 360
_defis deprecated, usedefor directly useoptions - line 393
zodErrorObj.errors[0]changes tozodErrorObj.issues[0] - line 410
union errorchanges toerrors - line 414 and 459,
receivedchanges tomessage - 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
- [x]
npm run lintpasses - [ ] Inline reference is included / updated
- [x] Unit tests are included / updated
🎉 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!
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?
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.
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
Thanks for your patience on this @madhav2348, I think this is good to go!
@all-contributors please add @madhav2348 for code