Skip to content

Function.pickKeys

github-actions[bot] edited this page Jul 8, 2026 · 20 revisions

umt / pickKeys

Function: pickKeys()

pickKeys<T, K>(validator, keys, message?): (value) => ValidateCoreReturnType<InferObject<Pick<T, K[number]>>> & object & StandardSchemaV1<InferObject<Pick<T, K[number]>>, InferObject<Pick<T, K[number]>>>

Defined in: Validate/object/pickKeys.ts:30

Picks the given keys from an existing object validator and returns a new object validator covering only those keys.

Type Parameters

T

T extends ObjectShape

Original object shape

K

K extends readonly keyof T[]

Tuple of keys to pick from the original shape

Parameters

validator

ObjectValidator<T>

Source object validator

keys

K

Keys to retain on the new validator

message?

string

Custom error message for the picked validator

Returns

(value) => ValidateCoreReturnType<InferObject<Pick<T, K[number]>>> & object & StandardSchemaV1<InferObject<Pick<T, K[number]>>, InferObject<Pick<T, K[number]>>>

  • New validator scoped to picked keys

API

Classes

Interfaces

Type Aliases

Variables

Functions

Clone this wiki locally