ArkEnv

Standard Schema validators

You can use any Standard Schema validator with ArkEnv.

ArkEnv supports any validator that implements the Standard Schema specification.

By default, ArkEnv runs validation through ArkType, which natively supports Standard Schema validators like Zod and Valibot. This lets you freely mix ArkType's string DSL with other validation libraries in the same schema.

If you prefer not to install ArkType, ArkEnv also provides a Standard-only mode that works with Standard Schema validators directly.

Supported validators

ArkEnv works with any validator that implements the Standard Schema interface, including:

  • Zod - TypeScript-first schema validation
  • Valibot - Modular schema validation
  • ArkType (native) - TypeScript's 1:1 validator

To read more about Standard Schema, see the Standard Schema documentation.

Using Standard Schema with ArkType (default)

Since ArkType natively supports Standard Schema, you can freely mix ArkType DSL strings with Standard Schema validators in the same schema—no configuration needed.

npm install arkenv arktype zod
pnpm add arkenv arktype zod
yarn add arkenv arktype zod
bun add arkenv arktype zod
env.ts
import  from 'arkenv';
import * as  from 'zod';

export const  = ({
  // ArkType DSL
  : "string.host",
  : "number.port",
  : "'development' | 'production' | 'test'",
  
  // Standard Schema (Zod)
  : .().(),
  : .().(32),
});

This is useful when:

  • You want ArkType's concise DSL for simple fields
  • You need library-specific features (transforms, refinements) for complex fields
  • You're migrating gradually from another validation library

Tip

This works with any Standard Schema validator, including Valibot. Just install your preferred validator and use it alongside ArkType DSL strings.

Using Standard Schema without ArkType

If you don't want ArkType installed, you can run ArkEnv in Standard-only mode by setting validator: "standard":

env.ts
import  from 'arkenv';
import {  } from 'zod';

export const  = (
  {
    : ..().().(0).(65535),
    : .().(),
    : ..().(false),
  },
  { : "standard" }
);

When to use Standard-only mode

  • You want a zero-ArkType runtime path
  • You're migrating from another validation library
  • You prefer Standard Schema validators exclusively
  • You want to minimize bundle size

Limitations

  • ArkType DSL strings are not supported (e.g., "number.port", "string.host")
  • ArkType coercion is not available - validators handle their own parsing

Need help?

If you run into issues:

  1. In default mode: Ensure you're using arktype@>=2.1.28
  2. Verify your validator library implements Standard Schema 1.0
  3. Join our Discord community for help