Skip to content

Function.optional

github-actions[bot] edited this page May 8, 2026 · 33 revisions

umt / optional

Function: optional()

optional<T, R>(validator): OptionalValidator<T, R>

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

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

OptionalValidator<T, R>

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

API

Classes

Interfaces

Type Aliases

Variables

Functions

Clone this wiki locally