Yup is a schema builder and validation library for JavaScript and TypeScript, designed for runtime value parsing and validation. It provides a fluent, chainable API to define schemas that can cast input values to the correct types and assert constraints. The library is built around a modular class hierarchy: a base Schema class provides common methods (validate, cast, isValid, etc.), and concrete types (StringSchema, NumberSchema, BooleanSchema, DateSchema, ArraySchema, ObjectSchema, TupleSchema) extend it with type-specific transforms and tests. MixedSchema allows arbitrary types with custom type guards. The library also supports lazy evaluation via LazySchema, conditional logic via when(), and references via Ref for cross-field validation. Yup is fully asynchronous by default but provides synchronous variants for use cases without async tests. It integrates with the Standard Schema specification for interoperability. External dependencies include property-expr for path expressions, tiny-case for string case transformations, toposort for dependency ordering, and type-fest for TypeScript utilities. The codebase is written in TypeScript with comprehensive type inference, allowing static types to be inferred from schema definitions. The architecture emphasizes immutability (each method returns a new schema instance) and composability (schemas can be concatenated, nested, and reused). Key entry points are the factory functions (string(), number(), boolean(), date(), object(), array(), tuple(), mixed(), lazy(), ref()) and the methods on schema instances (validate, cast, isValid, describe, etc.). The validation flow involves resolving conditions and references, running transforms (coercion pipeline), then executing tests (assertions). Errors are collected into ValidationError objects with detailed context.
Valibot is a modular, type-safe schema validation library for TypeScript with zero external dependencies. It provides a comprehensive set of schemas (string, number, object, array, union, etc.), validation actions (email, minLength, regex, etc.), transformation actions (toNumber, toUpperCase, parseJson, etc.), and composition methods (pipe, fallback, forward, cache). The library is tree-shakeable, supports both sync and async validation, and achieves 100% test coverage. Its architecture follows a consistent action/schema object pattern with a `~run` method for runtime validation and extensive TypeScript generics for type inference (InferInput, InferOutput, InferIssue). The repository is a monorepo containing the core library, a documentation website built with Qwik, a codemod for migrating from Zod to Valibot, a JSON Schema conversion package, and an i18n package for localized error messages. The primary entry point is `library/src/index.ts`, which re-exports all schemas, actions, methods, and utilities. Data flows involve defining schemas, optionally piping actions, and then calling `parse` or `safeParse` to validate input against the schema. The library implements the Standard Schema specification for interoperability.