Skip to content

Function.required

github-actions[bot] edited this page May 13, 2026 · 29 revisions

umt / required

Function: required()

required<T>(validator, message?): ObjectValidator<RequiredShape<T>>

Defined in: Validate/object/required.ts:28

Strips optional() wrappers from every property validator of validator. Validators that are not wrapped in optional() are kept as-is.

Type Parameters

T

T extends ObjectShape

Original object shape

Parameters

validator

ObjectValidator<T>

Source object validator

message?

string

Custom error message for the new validator

Returns

ObjectValidator<RequiredShape<T>>

  • New validator where every optional layer is removed

API

Classes

Interfaces

Type Aliases

Variables

Functions

Clone this wiki locally