Navigate:
~$YUP0.0%

Yup: Schema validation and parsing for runtime values

JavaScript schema validation with chainable API and type inference.

LIVE RANKINGS • 10:20 AM • STEADY
OVERALL
#424
68
DEVELOPER TOOLS
#90
14
30 DAY RANKING TREND
ovr#424
·Devel#90
STARS
23.7K
FORKS
941
7D STARS
+4
7D FORKS
+1
See Repo:
Share:

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.

Yup

1

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.

2

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.

3

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);


[ EXPLORE MORE ]

Related Repositories

Discover similar tools and frameworks used by developers