Skip to content

Function.optional

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

umt / optional

Function: optional()

optional<T>(validator): (value?) => ValidateCoreReturnType<T | undefined>

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

Wraps a validator to accept undefined values

Type Parameters

T

T

The type of value the wrapped validator expects

Parameters

validator

(value) => ValidateCoreReturnType<T>

Validator function to make optional

Returns

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

(value?) => ValidateCoreReturnType<T | undefined>

API

Classes

Interfaces

Type Aliases

Variables

Functions

Clone this wiki locally