Skip to content

Function: describe() ​

Set a description on a combinator schema for help text generation.

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

Signature ​

ts
export declare function describe<T, D extends string, S extends CombinatorSchema<T> = CombinatorSchema<T>>(schema: S, text: D): Modified<S, CombinatorDescribe<D>>

Type Parameters ​

NameDescription
TThe schema's parsed type, when type arguments are given explicitly. It is not inferred, so that schema can be a union of schemas of different types.
D extends stringThe description string literal type.
S extends CombinatorSchema<T> = CombinatorSchema<T>The input combinator schema, inferred from schema. Its other modifiers are kept. If type arguments are given explicitly without S, S is CombinatorSchema<T>, and the type of the result lacks the other modifiers, although the returned object has them.

Parameters ​

NameTypeDescription
schemaSThe base combinator schema.
textDHuman-readable description.

Returns ​

Modified<S, CombinatorDescribe<D>> — A new schema with the description set.

Examples ​

ts
const args = {
  port: describe(integer(), 'Port number to listen on')
}

Released under the MIT License.