Why Runtime Validation?
Understand the fundamental boundary between compile-time TypeScript types and real-world runtime data.
TypeScript Types vs Runtime Reality
Declaring `type User = { id: string, age: number }` tells the compiler what you expect, but if an API caller passes `{ id: 123, age: 'twenty' }`, TypeScript cannot protect you at runtime. Subatom Infer acts as the runtime guardian that checks shapes and asserts types.
Schema Definition
// Compile-time only (does NOT validate at runtime)
interface PostInput {
title: string;
tags: string[];
}
// Subatom Infer: Validates at runtime AND infers identical TypeScript types
const PostSchema = infer.object({
title: infer.string().min(1),
tags: infer.array(infer.string()).nonempty()
});
type Post = Infer<typeof PostSchema>;Crossing Trust Boundaries
Whenever data enters from external sources—HTTP requests, JSON files, environment variables, or databases—you are at a trust boundary. Subatom Infer transforms unknown input into verified, typed domain values.
Security & Zero Dependencies
Built with zero third-party dependencies, Subatom Infer eliminates supply chain vulnerabilities while delivering minimal bundle footprint and top-tier execution speeds.
