Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/valibot/src/schemas/index.ts>variant

The modular and type safe schema library for validating structural data 🤖
Extremely Popular
Go to Latest
function variant
import { variant } from "https://deno.land/x/valibot@v0.28.1/src/schemas/index.ts";

Creates a variant (aka discriminated union) schema.

Type Parameters

TKey extends string
TOptions extends VariantOptions<TKey>

Parameters

key: TKey

The discriminator key.

options: TOptions

The variant options.

optional
pipe: Pipe<Output<TOptions[number]>>

A validation and transformation pipe.

Returns

A variant schema.

Creates a variant (aka discriminated union) schema.

Type Parameters

TKey extends string
TOptions extends VariantOptions<TKey>

Parameters

key: TKey

The discriminator key.

options: TOptions

The variant options.

optional
message: ErrorMessage

The error message.

optional
pipe: Pipe<Output<TOptions[number]>>

A validation and transformation pipe.

Returns

A variant schema.