noamr
2022-11-09
It’s common today to perform schema validation on incoming JSON from an HTTP response, e.g. with tools like ZOD (GitHub - colinhacks/zod: TypeScript-first schema validation with static type inference).
What if the web platform provided this in a standard, performant and non-blocking way? It would make it much easier to avoid a very common type of bugs without blocking the main thread, creating new service-worker code, or having to choose between all kinds of schema validation libs.
Strawman API:
const response = await fetch("...");
const data = await response.json({schema: "my-json-schema.json"});