---
title: validation
description: Standard Schema utilities and ValidationError helpers for one consistent validation flow across schema libraries.
sidebar:
  label: Overview
type: package
package: "@zap-studio/validation"
---

`validation` provides utilities for validating values using the [**Standard Schema**](https://standardschema.dev/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-exports** — `StandardSchemaV1` and `StandardTypedV1` directly from this package.
- **Tree-shakeable** — every helper is a standalone function; unused exports are dropped by any modern bundler.

## Quick Start

```ts
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

- [Getting Started](/validation/getting-started) — install and validate your first payload
- [Async Validation](/validation/async-validation) — `standardValidate`
- [Synchronous Validation](/validation/synchronous-validation) — `standardValidateSync`
- [Create Validators](/validation/create-validators) — reusable validator functions
- [Errors](/validation/errors) — `throwOnError` and `ValidationError`
- [Runtime Schema Detection](/validation/runtime-schema-detection) — `isStandardSchema`

## 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`).
