Skip to content

Function.required

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

umt / required

Function: required()

required<T>(validator, message?): (value) => ValidateCoreReturnType<InferObject<RequiredShape<T>>> & object & StandardSchemaV1<InferObject<RequiredShape<T>>, InferObject<RequiredShape<T>>>

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

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

(value) => ValidateCoreReturnType<InferObject<RequiredShape<T>>> & object & StandardSchemaV1<InferObject<RequiredShape<T>>, InferObject<RequiredShape<T>>>

  • New validator where every optional layer is removed

API

Classes

Interfaces

Type Aliases

Variables

Functions

Clone this wiki locally