[Backend] Add TS Schema Runtime Checking for Incoming Data
Closed this issue · 5 comments
bglossner commented
Title
bglossner commented
Some options:
- io-ts
- typescript-json-schema WITH ajv
Wanting to try 2nd option. It just feels familiar
bglossner commented
Perhaps should look at JOI and joi-to-typescript instead.
bglossner commented
Ok, now the choices are up to:
- JOI + joi-to-typescript - this, albeit fast, is the largest package and requires 2 packages to make it work so we can automatically convert from the schema to TS. Probably a bit glitchy too. Meh support (not too many commits lately).
- Zod - zero dependencies. Not sure on speed (seems meh) but great support and active devs. Type inference is decent. Sorta leaning towards this one
Superstruct- severely lacks in existing featureset.- Class validator - uses classes instead so types are sorta built in. Get nice annotation stuff. Pretty fast
Yup- decent but slower than JOI (smaller bundle though). Familiar feeling schema but TS type inference is not the best. Probably gets better with time. Large support. Not actively developed right now
bglossner commented
Think I'm gonna try out Zod for now.