Skip to content

Function: number()

WARNING

This API is experimental and may change in future versions.

Create a number argument schema with optional range validation.

Accepts any numeric value (integer or float).

Signature

ts
declare function number(opts?: NumberOptions): CombinatorSchema<number>

Parameters

NameTypeDescription
optsNumberOptionsRange options. (optional)

Returns

CombinatorSchema<number> — A combinator schema that resolves to number.

Examples

ts
const args = {
  timeout: number({ min: 0, max: 30000 })
}

Released under the MIT License.