tosijs-schema: A Schema-First Validation Library Using JSON Schema as Source of Truth
By
podperson
A five-star bake. Worth schmearing, sharing, saving.
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 pulledIf 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.
You might also wanna read
Cursor: AI-Powered Code Editor for Enhanced Developer Productivity
Cursor is an AI-powered code editor designed to significantly boost developer productivity by integrating AI assistance directly into the co
Haystack: AI-Powered Code Review Platform That Turns Pull Requests into Clear Narratives
Haystack is an AI-native code review platform that transforms pull request reviews from confusing jigsaw puzzles into clear narrative storie
Cline: AI-Powered Autonomous Coding Assistant for Visual Studio Code
Cline is an AI-powered autonomous coding agent for VS Code that can understand code context, generate code, answer questions, and perform co
Coddo: A Task-First Software Development Tool with AI Integration
Coddo is a task-first software development tool that differs from traditional IDEs like VS Code by organizing work around tasks rather than
Warp Platform: Terminal and Orchestration Tools for Building Coding Agents Locally and in the Cloud
Warp is a terminal platform designed specifically for building and running coding agents, offering both local and cloud-based capabilities.
Zed Code Editor Reaches 1.0 After Rebuilding from Scratch Without Electron
Zed, a new code editor built from scratch by the creators of Atom, has reached version 1.0. The team abandoned the Electron/web technology a
