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

x/valibot/src/methods/index.ts>pick

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

Creates an object schema that contains only the selected keys of an existing schema.

Type Parameters

TObjectSchema extends ObjectSchema<any>
TKeys extends (keyof TObjectSchema["object"])[]

Parameters

The schema to pick from.

keys: TKeys

The selected keys

optional
pipe: Pipe<ObjectOutput<Pick<TObjectSchema["object"], TKeys[number]>>>

A validation and transformation pipe.

Returns

ObjectSchema<Pick<TObjectSchema["object"], TKeys[number]>>

An object schema.

Creates an object schema that contains only the selected keys of an existing schema.

Type Parameters

TObjectSchema extends ObjectSchema<any>
TKeys extends (keyof TObjectSchema["object"])[]

Parameters

The schema to pick from.

keys: TKeys

The selected keys

optional
error: string

The error message.

optional
pipe: Pipe<ObjectOutput<Pick<TObjectSchema["object"], TKeys[number]>>>

A validation and transformation pipe.

Returns

ObjectSchema<Pick<TObjectSchema["object"], TKeys[number]>>

An object schema.