Skip to main content
Module

x/valibot/mod.ts>pick

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

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

Type Parameters

TSchema extends ObjectSchema<any, any>
TKeys extends (keyof TSchema["entries"])[]

Parameters

schema: TSchema

The schema to pick from.

keys: TKeys

The selected keys

optional
pipe: Pipe<ObjectOutput<Pick<TSchema["entries"], TKeys[number]>, undefined>>

A validation and transformation pipe.

Returns

ObjectSchema<Pick<TSchema["entries"], TKeys[number]>>

An object schema.

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

Type Parameters

TSchema extends ObjectSchema<any, any>
TKeys extends (keyof TSchema["entries"])[]

Parameters

schema: TSchema

The schema to pick from.

keys: TKeys

The selected keys

optional
message: ErrorMessage

The error message.

optional
pipe: Pipe<ObjectOutput<Pick<TSchema["entries"], TKeys[number]>, undefined>>

A validation and transformation pipe.

Returns

ObjectSchema<Pick<TSchema["entries"], TKeys[number]>>

An object schema.

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

Type Parameters

TSchema extends ObjectSchema<any, any>
TKeys extends (keyof TSchema["entries"])[]
TRest extends BaseSchema | undefined

Parameters

schema: TSchema

The schema to pick from.

keys: TKeys

The selected keys

rest: TRest

The object rest.

optional
pipe: Pipe<ObjectOutput<Pick<TSchema["entries"], TKeys[number]>, TRest>>

A validation and transformation pipe.

Returns

ObjectSchema<Pick<TSchema["entries"], TKeys[number]>, TRest>

An object schema.

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

Type Parameters

TSchema extends ObjectSchema<any, any>
TKeys extends (keyof TSchema["entries"])[]
TRest extends BaseSchema | undefined

Parameters

schema: TSchema

The schema to pick from.

keys: TKeys

The selected keys

rest: TRest

The object rest.

optional
message: ErrorMessage

The error message.

optional
pipe: Pipe<ObjectOutput<Pick<TSchema["entries"], TKeys[number]>, TRest>>

A validation and transformation pipe.

Returns

ObjectSchema<Pick<TSchema["entries"], TKeys[number]>, TRest>

An object schema.