Skip to content

Function.optional

github-actions[bot] edited this page Jun 29, 2026 · 33 revisions

umt / optional

Function: optional()

optional<T, R>(validator): (value?) => UndefinedReturn | R & object & StandardSchemaV1<T | undefined, T | undefined>

Defined in: Validate/object/optional.ts:37

Wraps a validator to accept undefined values

Type Parameters

T

T

The type of value the wrapped validator expects

R

R extends object

The return type of the wrapped validator (preserved so the inner type tag flows through)

Parameters

validator

(value) => R

Validator function to make optional

Returns

(value?) => UndefinedReturn | R & object & StandardSchemaV1<T | undefined, T | undefined>

  • Validator that passes for undefined or delegates to the wrapped validator

API

Classes

Interfaces

Type Aliases

Variables

Functions

Clone this wiki locally