Our great sponsors
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
-
ajv
The fastest JSON schema Validator. Supports JSON Schema draft-04/06/07/2019-09/2020-12 and JSON Type Definition (RFC8927)
I think you want something like zod for this.
typebox - https://github.com/sinclairzx81/typebox
I'll throw https://github.com/woutervh-/typescript-is in the mix as well.
If you are ingesting data from a 3rd party api you probably want to use a validation library to validate the payload and type it. Especially if it’s undocumented. We use Ajv at my current job and it’s pretty awesome. https://ajv.js.org/
It's an NPM package tiny-schema-validator
Also runtypes and (as mentioned below) zod.
Related posts
- Typescript Runtime Validators and DX, a type-checking performance analysis of zod/superstruct/yup/typebox
- Schema validation using only TypeScript types?
- Input validation in Express from TypeScript
- TypeScript runtime type-checking - designed for simple use, through to enforcing API payload schema
- Popular Libraries For Building Type-safe Web Application APIs