Skip to content
Zap Studio
validation
Esc
navigateopen⌘Jpreview
On this page

validation

Standard Schema utilities and ValidationError helpers for one consistent validation flow across schema libraries.

validation provides utilities for validating values using the Standard Schema specification.

Motivation

Zod throws a ZodError. Valibot returns a result object. ArkType has its own shape. If your code — or a library you are writing — needs to support more than one of these, or wants to let its users bring whichever one they prefer, you end up writing different error-handling code for each.

And if you ever switch from one to another, every call site that touches validation needs to change too.

validation removes this difference. standardValidate and standardValidateSync give you one function and one ValidationError shape, no matter which Standard Schema library sits underneath.

Validation code becomes portable: swap the schema library later, and the code that calls it does not need to change.

Features

  • Async-safe validation via standardValidate, works with sync and async schemas.
  • Synchronous validation via standardValidateSync, for schemas known to validate synchronously.
  • Reusable validators via createStandardValidator and createStandardValidatorSync.
  • Optional throwing behavior via throwOnError, backed by a shared ValidationError class.
  • Runtime schema detection via isStandardSchema.
  • Type re-exportsStandardSchemaV1 and StandardTypedV1 directly from this package.
  • Tree-shakeable — every helper is a standalone function; unused exports are dropped by any modern bundler.

Quick Start

import { standardValidate } from "@zap-studio/validation";

// `userSchema` can come from any Standard Schema-compatible library
try {
  const user = await standardValidate(input, userSchema, {
    throwOnError: true,
  });

  console.log("Validation passed:", user);
} catch (error) {
  console.error("Validation failed:", error);
}

Learn More

Runtime Support

Runtime Minimum version
Node.js 18.0.0
Bun 1.0.0
Deno 1.42
Cloudflare Workers Any current release
Browsers Latest evergreen (Chrome, Edge, Firefox, Safari)

The package ships standard ESM only and uses no runtime-specific APIs. Deno 1.42 is the first release that can install packages from JSR (deno add jsr:@zap-studio/validation).

Last updated on September 15, 2026

Was this page helpful?