Skip to content

Function.oneOf

github-actions[bot] edited this page May 5, 2026 · 32 revisions

umt / oneOf

Function: oneOf()

oneOf<T>(values, message?): ValidateReturnType<string>

Defined in: Validate/string/oneOf.ts:19

Creates a validator for checking if a string is included in the given allowed values. Equivalent to checking membership in a string literal union type.

Type Parameters

T

T extends string

The allowed string literal type

Parameters

values

readonly T[]

The list of allowed string values

message?

string

Custom error message for validation failure

Returns

ValidateReturnType<string>

  • Validator for allowed string values

API

Classes

Interfaces

Type Aliases

Variables

Functions

Clone this wiki locally