Yup: Schema validation and parsing for runtime values
JavaScript schema validation with chainable API and type inference.
Learn more about yup
Yup is a JavaScript schema validation library that combines parsing (value transformation) and assertion (validation testing) into a chainable API. It works by defining schemas composed of type definitions and validation rules, then applying those schemas to input values through validate(), validateSync(), or cast() methods. The library generates detailed error information when validation fails and supports complex interdependent validations across nested objects and arrays. Common use cases include form validation in web applications, API request/response validation, and data transformation pipelines.
TypeScript type inference
Schemas can automatically generate static TypeScript types via the InferType utility, allowing type safety without manual type definitions. Conversely, existing TypeScript types can be validated against schemas to ensure correctness.
Async validation support
Built-in support for asynchronous validation rules enables server-side validation checks and cross-field async operations within the same schema definition, rather than requiring separate client and server validation logic.
Parsing and validation combined
Schemas handle both type coercion and validation in a single pass. The cast() method performs type conversion without assertions, while validate() applies both transformations and tests, allowing flexible usage patterns.
import * as yup from 'yup';
const userSchema = yup.object({
email: yup.string().email().required(),
age: yup.number().positive().integer().min(18)
});
const userData = { email: 'user@example.com', age: 25 };
const validUser = await userSchema.validate(userData);Release notes link to GitHub issue #1906 without inline details; breaking changes and migration steps are not specified here.
- –Review issue #1906 on GitHub to identify breaking changes before upgrading production systems.
- –Release notes do not specify new requirements, deprecations, or migration procedures in the provided text.
Fixes published artifacts for the `main` field; no functional changes reported.
- –Update to v1.0.0-beta.7 if you experienced module resolution errors with the previous beta release.
- –Release notes do not specify breaking changes, new requirements, or feature additions beyond the packaging fix.
Fixes partial/deepPartial to apply optionality after lazy evaluation but before when conditions; adds cast option to ease migration from v1 breaking changes.
- –Use cast({assert: 'ignore-optionality'}) to temporarily allow patterns like string().nullable().required() during migration.
- –Update schemas relying on partial with lazy or when—optionality now applies after lazy resolves but before runtime conditions.
Related Repositories
Discover similar tools and frameworks used by developers
JetBrainsMono
Monospaced typeface optimized for coding with ligatures.
responsive-html-email-template
Cross-client HTML email starter with inline CSS support.
chenyuluoyan_thin
A refined thin-weight Chinese font family designed for modern digital interfaces, offering graceful readability and aesthetic appeal for web and application typography.
vite
Native ESM dev server with Rollup production builds.
react-router
Component-based navigation and URL management for React.