All Topics
All Topics
Technology
Technology
Design
Design
Programming
Programming
Science
Science
News
News
Gaming
Gaming
Entertainment
Entertainment
Business
Business
Finance
Finance
Sports
Sports
Health
Health
Food
Food
Travel
Travel
Art
Art
Music
Music
Books
Books
Education
Education
Politics
Politics
Personal
Personal
No algorithm. No AI slop. No ads. Just RSS. Pro-human. Indie writers. Real journalism. Open web. Chronological. Hand toasted.

tosijs-schema: A Schema-First Validation Library Using JSON Schema as Source of Truth

By

podperson

6mo ago· 6 min readenInsight

Summary

tosijs-schema is a schema-first validation library that positions JSON Schema as the source of truth for data validation, contrasting with Zod's approach of deriving validation from TypeScript types. The library enables developers to define schemas once and derive both TypeScript types and validation logic from them, making it particularly useful for data that crosses boundaries like APIs, LLMs, databases, or documentation. The article explains the library's philosophy, compares it to Zod, and provides implementation details and usage examples.

Key quotes

· 4 pulled
If your data crosses any boundary—API, LLM, database, another language, documentation—you need a schema. If you need a schema anyway, why isn't that the source of truth?
Zod's premise: TypeScript is the source of truth → derive validation → convert to JSON Schema when needed
Schema-first premise: The schema IS the source of truth → derive both types AND validation
A schema-first validation library. Define schemas, infer TypeScript types, validate efficiently.
Snippet from the RSS feed
Latest version: 1.3.0, last published: 3 months ago. Start using tosijs-schema in your project by running `npm i tosijs-schema`. There are 3 other projects in the npm registry using tosijs-schema.

You might also wanna read