Revamp Friendly Error System's Parameter Validation
Open
@sproutleaf is already working on this.
Since Aug 15, 2024.
Enhancement
Friendly Errors
- Dominant language
- JavaScript
- Stars
- 24k
- Forks
- 3.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 25
Description
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
- Friendly errors
- Other (specify if possible)
Feature Enhancement Details
Migrate the parameter validation flow in FES to Zod.
Main task list:
- Use the new modular syntax for the param validator
- Add test file for new param validator
- Validate against real p5 constructors
- Account for less frequently used types (i.e. AudioNode)
- Handle schema generation for optional parameters.
- Validate against real p5 constants.
- Implement a distance calculation mechanism similar to
scoreOverloadthat gives user the proper error message when parameter validation fails. - Update script that generates
parameterData.jsonto further reduce the information load.
New bugs discovered / TODOs after introducing changes:
-
cursor's overload is different from expectation (a mix of constants and primitive types) -
createAudiooverload is an array of empty arrays - 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.