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. Other modifiers on schema (for example multiple) are kept.

Signature

ts
declare function required<S extends CombinatorSchema<unknown>>(schema: S): WithFlag<S, CombinatorRequired>

Type Parameters

NameDescription
S extends CombinatorSchema<unknown>The input combinator schema.

Parameters

NameTypeDescription
schemaSThe base combinator schema.

Returns

WithFlag<S, CombinatorRequired> — A copy of schema with required: true.

Examples

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

Released under the MIT License.