p5.js
p5.js copied to clipboard
Revamp Friendly Error System's Parameter Validation
Most Appropriate Sub-area of p5.js?
- [ ] Accessibility
- [ ] Color
- [ ] Core/Environment/Rendering
- [ ] Data
- [ ] DOM
- [ ] Events
- [ ] Image
- [ ] IO
- [ ] Math
- [ ] Typography
- [ ] Utilities
- [ ] WebGL
- [ ] Build process
- [ ] Unit testing
- [ ] Internationalization
- [X] Friendly errors
- [ ] Other (specify if possible)
Feature Enhancement Details
Migrate the parameter validation flow in FES to Zod.
Main task list:
- [x] Use the new modular syntax for the param validator
- [x] Add test file for new param validator
- [x] Validate against real p5 constructors
- [x] Account for less frequently used types (i.e. AudioNode)
- [x] Handle schema generation for optional parameters.
- [x] Validate against real p5 constants.
- [x] Implement a distance calculation mechanism similar to
scoreOverload
that gives user the proper error message when parameter validation fails. - [x] Update script that generates
parameterData.json
to further reduce the information load.
New bugs discovered / TODOs after introducing changes:
- [x]
cursor
's overload is different from expectation (a mix of constants and primitive types) - [x]
createAudio
overload is an array of empty arrays - [x] Add support for
lerpPalette
's parameter, see #6960 - [ ] Agree on a most appropriate way to format and present error messages (mostly done, might require more work upon Ken's feedback)
To be completed before wrapping up the project:
- [ ] Use the new parameter validation in p5
- [ ] Clean up old code