kavitayadav54/yup

Dead simple Object schema validation

⭐ 0 stars💬 2 comments

Files

📄 .babelrc.js415 B
📄 .eslintignore23 B
📄 .eslintrc707 B
📄 .gitattributes483 B
📁 .github
📄 .gitignore1.2 KB
📄 .nvmrc8 B
📁 .yarn
📄 .yarnrc.yml25 B
📄 CHANGELOG.md46.8 KB
📄 LICENSE.md1.1 KB
📄 README.md61.7 KB
📁 docs
📄 package.json3 KB
📄 renovate.json82 B
📄 rollup.config.js829 B
📁 src
📁 test
📄 test-setup.mjs583 B
📄 tsconfig.json148 B
📄 vitest.config.ts691 B
📄 yarn.lock551.4 KB

README

# Yup Yup is a schema builder for runtime value parsing and validation. Define a schema, transform a value to match, assert the shape of an existing value, or both. Yup schema are extremely expressive and allow modeling complex, interdependent validations, or value transformation. > **You are viewing docs for the v1.0.0 of yup, pre-v1 docs are available: [here](https://github.com/jquense/yup/tree/pre-v1)** **Killer Features**: - Concise yet expressive schema interface, equipped to model simple to complex data models - Powerful TypeScript support. Infer static types from schema, or ensure schema correctly implement a type - Built-in async validation support. Model server-side and client-side validation equally well - Extensible: add your own type-safe methods and schema - Rich error details, make debugging a breeze - Compatible with [Standard Schema](https://github.com/standard-schema/standard-schema) ## Getting Started Schema are comprised of parsing actions (transforms) as well as assertions (tests) about the input value. Validate an input value to parse it and run the configured set of assertions. Chain together methods to build a schema. ```ts import { object, string, number, date, InferType } from 'yup'; let userSchema = object({ name: string().required(), age: number().required().positive().integer(), email: string().email(), website: string().url().nullable(), createdOn: date().default(() => new Date()), }); // parse and assert validity let user = await userSchema.validate(await fetchUser()); type User = InferType<typeof userSchema>; /* { name: string; age: number; email?: string | undefined website?: string | null | undefined createdOn: Date }*/ ``` Use a schema to coerce or "cast" an input value into the correct type, and optionally transform that value into more concrete and specific values, without making further assertions. ```ts // Attempts to coerce values to the correct type let parsedUser = userSchema.cast({ name: 'ji

Discussion

sarthak2026-07-19 03:19:51

jjjjjjjj

sarthak2026-07-19 03:19:38

hi

SocialRepo
Login

loading/repo...

Latest Updates

Discussion