Schema Validation
Checking data against a declared shape at runtime, and using the result as the typed value.
Schema validation is checking incoming data against a declared structure before trusting it. In typed languages the modern idiom is parse, don't validate: rather than asserting that an unknown value has a type, run it through a parser that returns a typed value or fails. The type then rests on an actual check rather than a claim.
That distinction matters because the alternative — a type assertion — is a promise the compiler accepts and never verifies. A cast asserting that a value conforms is exactly as strong as the author's belief, which is to say not at all. Where a value is already typed and merely needs re-expressing as the schema's type, running it through the parser is both safer and clearer than casting: the parser accepts unknown input by design, so no cast is needed, and permissive object schemas pass unrecognized fields through unchanged.
Two operational notes. A guard claiming a value is both A and B, backed by a check for only B, is unsound — it asserts the unchecked half. And where schemas grow large, keeping them in a dedicated module rather than inline keeps the module's actual exports readable.
Validation is the natural boundary for a system taking model output; see Structured Output.
See also13
JSON Schema
A vocabulary for describing the shape of JSON data, and the lingua franca of model tool interfaces.
Agents & Language Models14 connections
Fail Fast
Crash at the point of misconfiguration rather than degrading quietly into a wrong state.
Method27 connections
Schema Drift
Divergence between a schema and the code, types, or documentation that describe it.
Data & Content16 connections
Constrained Decoding
Restricting a model's next-token choices to those a formal grammar permits.
Agents & Language Models11 connections
Tool Use
Giving a model a set of callable functions so it can act on the world rather than only describe it.
Agents & Language Models27 connections
Unreachable Code
Code no input can execute — usually a guard against a state the surrounding invariants forbid.
Testing & Verification11 connections
Prompt Engineering
Shaping a model's input to make the desired behavior reliable rather than occasional.
Agents & Language Models22 connections
Large Language Model
A neural network trained to predict text, used as a general-purpose instruction-following system.
Agents & Language Models38 connections
Design by Contract
Specifying what each function requires and guarantees, as checkable preconditions, postconditions, and invariants, so a violation says exactly whose bug it is.
Testing & Verification12 connections
Form Validation
Checking what people type into a web form before accepting it, done in the browser for fast feedback and on the server for safety, and harder than it looks because real names, addresses, and numbers break simple rules.
Web Platform11 connections
SQL Injection
An attack in which user input is pasted into a database query and gets run as code, prevented by keeping the query and its data in separate channels.
Data & Content15 connections
Type System
The rules a language uses to classify values and reject operations that don't fit, checked before the program runs or as it runs, and the cheapest form of verification most programmers use every day.
Testing & Verification12 connections
Prototype Pollution
A JavaScript vulnerability where attacker-controlled keys like "__proto__" modify the prototype every object inherits from, silently adding properties everywhere, and how merge utilities and parsers let it in.
Web Platform10 connections
Linked from19
- Constrained DecodingAgents & Language Models
Restricting a model's next-token choices to those a formal grammar permits.
- Defensive DefaultMethod
A substituted value that papers over a missing input and hides the misconfiguration that produced it.
- Design by ContractTesting & Verification
Specifying what each function requires and guarantees, as checkable preconditions, postconditions, and invariants, so a violation says exactly whose bug it is.
- Duck TypingComputation & Algorithms
Treating an object as suitable for a role based on what it can do, not what type it's declared to be.
- Fair-Play MysteryMeaning & Society
The convention that a detective story must give the audience every clue it needs to solve the case.
- Form ValidationWeb Platform
Checking what people type into a web form before accepting it, done in the browser for fast feedback and on the server for safety, and harder than it looks because real names, addresses, and numbers break simple rules.
- Goodhart's LawMethod
When a measure becomes a target, it stops being a good measure.
- JSON SchemaAgents & Language Models
A vocabulary for describing the shape of JSON data, and the lingua franca of model tool interfaces.
- MonadComputation & Algorithms
A wrapper type with a way to lift a value in and a way to chain functions that return more wrappers.
- Prototype PollutionWeb Platform
A JavaScript vulnerability where attacker-controlled keys like "__proto__" modify the prototype every object inherits from, silently adding properties everywhere, and how merge utilities and parsers let it in.
- Schema DriftData & Content
Divergence between a schema and the code, types, or documentation that describe it.
- Schema EvolutionData & Content
Changing the shape of stored or transmitted data without breaking the old readers and writers that still expect the previous shape.
- SQL InjectionData & Content
An attack in which user input is pasted into a database query and gets run as code, prevented by keeping the query and its data in separate channels.
- Structured OutputAgents & Language Models
Constraining a model to emit data conforming to a declared schema rather than free text.
- Tool UseAgents & Language Models
Giving a model a set of callable functions so it can act on the world rather than only describe it.
- Type InferenceComputation & Algorithms
A compiler deriving a value's type from how it's used, so a programmer doesn't have to write it down.
- Type SystemTesting & Verification
The rules a language uses to classify values and reject operations that don't fit, checked before the program runs or as it runs, and the cheapest form of verification most programmers use every day.
- TypeScriptWeb Platform
Microsoft's typed superset of JavaScript, whose types are checked at build time and erased at runtime, and the deliberate trade-offs that made it the default for large web codebases.
- Unreachable CodeTesting & Verification
Code no input can execute — usually a guard against a state the surrounding invariants forbid.