Skip to content

Function: required() ​

Mark a combinator schema as required.

The original schema is not modified. Other modifiers on schema (for example multiple) are kept.

Signature ​

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

Type Parameters ​

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

Parameters ​

NameTypeDescription
schemaSThe base combinator schema.

Returns ​

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

Examples ​

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

Released under the MIT License.