Function: number()
Call Signature
ts
export declare function number<const R extends boolean>(opts: NumberOptions & {
required: R;
}): WithRequiredOption<CombinatorSchema<number>, R>Create a number argument schema with optional range validation.
Accepts any numeric value (integer or float).
Type Parameters
| Name | Description |
|---|---|
R extends boolean | The type of required in the options, which the schema keeps. |
Parameters
| Name | Type | Description |
|---|---|---|
opts | NumberOptions & { required: R } | Range options. |
Returns
WithRequiredOption<CombinatorSchema<number>, R> — A combinator schema that resolves to number.
Examples
ts
const args = {
timeout: number({ min: 0, max: 30000 })
}Call Signature
ts
export declare function number<const R extends boolean | undefined = boolean | undefined>(opts?: NumberOptions & {
required?: R;
}): WithUnrequiredOption<CombinatorSchema<number>, R>Create a number argument schema with optional range validation.
Accepts any numeric value (integer or float).
Type Parameters
| Name | Description |
|---|---|
R extends boolean | undefined = boolean | undefined | The type of required in the options, which the schema keeps when it may be false but not true, as for optional ? { required: false } : {}, so that a positional argument with it is optional. |
Parameters
| Name | Type | Description |
|---|---|---|
opts | NumberOptions & { required?: R } | Range options. (optional) |
Returns
WithUnrequiredOption<CombinatorSchema<number>, R> — A combinator schema that resolves to number.
Examples
ts
const args = {
timeout: number({ min: 0, max: 30000 })
}Call Signature
ts
export declare function number(opts?: NumberOptions): CombinatorSchema<number>Create a number argument schema with optional range validation.
Accepts any numeric value (integer or float).
Parameters
| Name | Type | Description |
|---|---|---|
opts | NumberOptions | Range options. (optional) |
Returns
CombinatorSchema<number> — A combinator schema that resolves to number.
Examples
ts
const args = {
timeout: number({ min: 0, max: 30000 })
}