You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Essentially it means coming up with a custom validation library, which requires lots of effort and could miss validations and/or contain bugs.
Instead of spending more time on custom validation logic, instead use a validation library which will do it automatically.
JSON schema is one obvious option, but it requires a lot of work to define the JSON schema files. JavaScript does not contain enough information for proper validation, but TypeScript does.
Recommendation to use Zod
Zod is a TypeScript-first schema declaration and validation library. With Zod, you declare a validator once and Zod will automatically infer the static TypeScript type
Currently package metadata is committed to git as freely-typed yaml files.
When the Registry is built, Yaml files are converted to JSON and checked with some custom validation logic:
https://github.com/open-audio-stack/open-audio-stack-core/blob/main/src/helpers/package.ts#L86
Things to validate:
Essentially it means coming up with a custom validation library, which requires lots of effort and could miss validations and/or contain bugs.
Instead of spending more time on custom validation logic, instead use a validation library which will do it automatically.
JSON schema is one obvious option, but it requires a lot of work to define the JSON schema files. JavaScript does not contain enough information for proper validation, but TypeScript does.
Recommendation to use Zod
https://github.com/colinhacks/zod
This allows validators to be defined in TypeScript, which can be used for both Types and for Validations. Reducing the amount of code required.
The text was updated successfully, but these errors were encountered: