这些库为 TypeScript 应用中的运行时数据提供了基于模式的验证和类型安全解析。
Zod is a TypeScript-first schema declaration and validation library designed to ensure end-to-end data integrity. It functions as a runtime type guard, allowing developers to define complex data structures through a declarative, chainable syntax. By using these schema definitions, the library automatically derives static TypeScript types, eliminating the need for manual type duplication and ensuring that runtime data matches expected application contracts. The library distinguishes itself through functional schema composition, which enables the creation of hierarchical structures by nesting a
Zod is a TypeScript-first schema declaration and validation library that automatically infers static types from runtime definitions, supports custom validators, async validation, unions, discriminated unions, and recursive schemas — fitting every requirement for a runtime type validation library with first-class TypeScript inference.
Superstruct is a JavaScript and TypeScript data validation library used to verify that data structures match defined shapes and types. It functions as a composable schema builder and a TypeScript schema validator, ensuring that runtime data checks remain synchronized with static type definitions. The library features a data coercion engine that transforms input values or injects default values before the validation process is executed. It enables the creation of complex validation rules by nesting, merging, or omitting properties from existing structures. Its capabilities cover the validatio
Superstruct is a TypeScript-first runtime validation library that infers static types from composable schemas, supports custom and async validators, unions, recursive definitions, and detailed error reporting—covering all the requested features.
Yup is a JavaScript schema validation library used to define data shapes and validate runtime values. It functions as an object schema validator and a data coercion engine, allowing developers to transform raw input values into desired types before performing validation checks. The library is distinguished by its support for dynamic schema validation, where rules can be adjusted at runtime based on sibling field values or external context. It also enables recursive data structuring for polymorphic fields and provides a system for extracting static TypeScript interfaces from runtime schema def
Yup is a widely-used schema validation library with first-class TypeScript support (it infers static types from runtime schemas), and it covers all the requested features including custom validators, async validation, unions via oneOf, and recursive schemas — making it an ideal fit for runtime data validation in TypeScript.
Valibot is a modular, type-safe schema library for validating and parsing structural data in TypeScript environments.
Valibot is a modular, TypeScript-first schema validation library that provides runtime validation, automatic type inference, and a pipeline-based transformation system, making it an excellent fit for your need for type-safe data structure validation.
async-validator is a JavaScript schema validation library and asynchronous data validation engine. It verifies complex object structures and nested arrays by applying recursive rules and non-blocking, promise-based execution to ensure data integrity. The library functions as both an object constraint validator and a data transformation pipeline. It allows for the sanitization, coercion, and formatting of input values through a sequence of functions that run before and after the primary validation process. The engine covers a range of capabilities including recursive nested validation, the en
async-validator is a schema-based validation library with async and custom rules, but it does not natively infer TypeScript types from schemas, which is a key requirement for your search.
TypeBox is a JSON schema generator and TypeScript data validator. It functions as a type builder that creates compliant JSON schema definitions while providing a mechanism for synchronizing runtime validation logic with compile-time types. The project allows for the automatic derivation of static TypeScript interfaces from schema definitions to eliminate redundant type declarations. It converts complex type constructs into schema fragments and resolves static types to maintain consistency between data shapes and code. The system covers runtime type checking and data validation through the us
TypeBox is a TypeScript-first runtime validation library that auto-derives static types from JSON schema definitions, providing full type inference, schema composition, custom validators, and support for unions and recursion — exactly what this search requires.
class-validator is a TypeScript class validation library that uses decorators to define constraints and rules for object properties. It functions as a decorator-based schema validator that ensures data integrity and structural correctness through a combination of synchronous checks and promise-based asynchronous rules. The library provides a recursive validation system for checking complex data hierarchies, including nested classes and individual elements within collections. It includes an object property whitelist utility capable of stripping undocumented properties or blocking unknown field
class-validator is a TypeScript library that validates object properties via decorators, with support for async, custom, and recursive validation, making it fit for runtime data structure validation, though its class-based approach differs from schema-driven type inference.
io-ts is a TypeScript runtime validation library that provides a composable codec system for decoding and encoding data at the boundaries of an application. It defines data schemas using structural types, where the shape of data determines its validity rather than nominal names, and produces runtime type guards from those definitions for efficient validation checks. The library is built around bidirectional codec mappings that combine decoding, encoding, and type checking into single reusable units. It supports a composable decoder pipeline where small validation steps can be chained together
io-ts is a TypeScript runtime validation library that uses composable codecs and produces type guards, fitting the request for a validation library, though the provided description does not explicitly confirm async or union support.
Typia is a compile-time code generator that transforms TypeScript type annotations into runtime validation, serialization, and schema functions without requiring decorators or separate schema files. It generates optimized validation and serialization code during TypeScript compilation, producing dedicated functions for each type that eliminate runtime schema objects for faster execution. The project extends this core capability into several integrated areas. It generates fully typed client SDKs from NestJS controller source code, keeping server and client types synchronized automatically. It
Typia is a TypeScript validation library that generates runtime validation functions directly from your existing TypeScript type annotations, giving you type inference and schema definitions without separate schema files – exactly the kind of tool this search targets, though its compile-time approach is a distinct trade-off compared to runtime-schema libraries.
Function argument validation for humans
Ow provides runtime validation for function arguments and objects with a fluent API and TypeScript support, which places it squarely in the runtime type validation category, though it focuses specifically on argument validation rather than full schema-based data structure validation, so it covers only some of the requested features like custom validators and error handling.