PACKAGE · VALIDATION

yup

Dead simple Object schema validation

WEEKLY DOWNLOADS 16.4M
STARS 23.6K
FORKS 960
OPEN ISSUES 274
GZIP SIZE 14.2 kB
UNPACKED SIZE 270.4 kB
DEPENDENCIES 4
LAST UPDATED 1y ago
DOWNLOAD TRENDS

yup downloads · last 12 months

Download trends for yup1 download series from Nov 2025 to Oct 2026. Use left and right arrow keys to inspect monthly values.014.8M29.6M44.3M59.1MNov 2025FebMayAugOct 2026
yup
ABOUT YUP

Yup validates JavaScript values against schemas, with a particular focus on objects and their fields. A schema describes the expected shape and constraints; validating data against it can catch missing, malformed, or out-of-range values before application code relies on them.

Yup’s “dead simple” object-schema focus suits developers who want validation rules expressed alongside the data shape they check. Its declarative approach makes constraints readable in code and gives applications a reusable description of expected input, rather than scattering checks across individual handlers.

The central pattern is to build schemas with Yup’s schema APIs, compose field rules into an object schema, and validate values against that schema. Validation can be used as a boundary check for data entering an application, while schema definitions can be kept near the forms or services that own the corresponding data model.

Yup fits JavaScript workflows that handle structured input, including form submission and request processing. It can sit between an input source and application logic: validate the incoming object first, then pass accepted data to later code, while handling validation failures where the user or caller can act on them.

The supplied package details report a 14.2 kB gzip bundle, a 270.4 kB unpacked size, and a 1.7.1 release under the MIT license. The reported 4.3M weekly downloads and 23.7K GitHub stars indicate substantial existing use; these figures describe the supplied package data, not a guarantee of fit or runtime speed.

Yup’s main scope is schema validation, so it does not by itself replace input collection, error presentation, or application-specific business logic. Treat validation rules as one boundary in a broader workflow, and verify that the schema’s treatment of optional fields, coercion, and asynchronous checks matches the behavior your application expects.

WHEN TO USE
  • Define the expected shape of form data with an object schema, then validate the submitted object before saving or processing it.
  • Centralize field constraints in Yup schema definitions so multiple input paths can validate against the same rules.
  • Check request payloads at an application boundary before passing their fields to business logic.
  • Use schema validation to report malformed or missing values instead of relying on scattered hand-written checks in individual handlers.
  • Keep validation rules close to the form or service that owns a structured data shape, and validate values at that point of use.
  • Add Yup when a JavaScript workflow needs reusable object validation and the reported 14.2 kB gzip bundle is acceptable for its delivery constraints.
WHEN NOT TO USE
  • Avoid Yup when you only need to check one or two primitive values; direct conditional checks can be clearer than defining an object schema.
  • Avoid it when validation must be expressed in a different schema language or runtime; use a validator that matches that required interface instead.
  • Avoid treating Yup as a form-rendering or error-display system; pair schema validation with your existing UI handling or choose a tool that owns that workflow.
  • Avoid relying on Yup schemas to enforce database constraints or authorization rules; enforce those requirements at the relevant persistence or security boundary as well.
  • Avoid adding its 14.2 kB gzip bundle to a tightly constrained client when the required checks can be implemented with smaller local code.
  • Avoid assuming schema validation alone defines application-specific business behavior; implement cross-field or domain rules explicitly where they belong.

CORRECTIONS

Spot wrong data here?

A short note helps us fix it.

Anonymous · No account · No email back

COMPARISONS 9
yup vs superstruct ★ 7.1K · 9.8M/wk yup vs joi ★ 21.2K · 33.6M/wk yup vs ajv ★ 14.9K · 535.1M/wk yup vs ow ★ 3.9K · 2.6M/wk yup vs zod ★ 44.4K · 462.8M/wk yup vs class-validator ★ 11.9K · 18.0M/wk yup vs fast-xml-parser ★ 3.1K · 114.6M/wk yup vs valibot ★ 9.1K · 35.1M/wk yup vs @sinclair/typebox ★ 15 · 166.1M/wk