Yup is a schema builder for runtime value parsing and validation, now at v1.7.1 with active development. It provides a concise, chainable API for defining schemas that can parse, coerce, and validate complex nested objects, with built-in async support and rich error details. Key differentiators include powerful TypeScript inference via InferType, seamless integration with Standard Schema, and extensibility through custom methods. It remains a top choice for form validation in React ecosystems (Formik) and general data validation, competing with Zod (more lightweight) and Joi (Node-only).
npm install yupNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Defines a user schema with required name, age, email, website, and createdOn fields, then validates an input object asynchronously.
Replace 'import yup from "yup"' with 'import { object, string, ... } from "yup"'Use await or .then() when calling .validate(). For synchronous casting, use .cast() instead.
Replace .validateSync() with await .validate() or use .cast() if you only need coercion.
Replace yup.mixed() with a concrete schema type (e.g., string(), number()) or use lazy() for dynamic schemas.
Use yup.lazy() to define recursive schemas. Example: const nodeSchema = object({ children: array().of(lazy(() => nodeSchema)) })Change import to named imports: import { string } from 'yup'Ensure input values are of the correct type, or use .transform() to handle coercion gracefully.
Ensure the schema variable is properly initialized before calling methods on it.
No dependency data recorded yet.