Skip to content

Function: required() ​

WARNING

This API is experimental and may change in future versions.

Mark a combinator schema as required.

The original schema is not modified.

Signature ​

ts
declare function required<T>(schema: CombinatorSchema<T>): CombinatorSchema<T> & CombinatorRequired

Type Parameters ​

NameDescription
TThe schema's parsed type.

Parameters ​

NameTypeDescription
schemaCombinatorSchema<T>The base combinator schema.

Returns ​

CombinatorSchema<T> & CombinatorRequired — A new schema with required: true.

Examples ​

ts
const args = {
  name: required(string())
}

Released under the MIT License.