Function: integer()
Call Signature
ts
export declare function integer<const R extends boolean>(opts: IntegerOptions & {
required: R;
}): WithRequiredOption<CombinatorSchema<number>, R>Create an integer argument schema with optional range validation.
Only accepts integer values (no decimals).
Type Parameters
| Name | Description |
|---|---|
R extends boolean | The type of required in the options, which the schema keeps. |
Parameters
| Name | Type | Description |
|---|---|---|
opts | IntegerOptions & { required: R } | Range options. |
Returns
WithRequiredOption<CombinatorSchema<number>, R> — A combinator schema that resolves to number (integer).
Examples
ts
const args = {
retries: integer({ min: 0, max: 10 })
}Call Signature
ts
export declare function integer<const R extends boolean | undefined = boolean | undefined>(opts?: IntegerOptions & {
required?: R;
}): WithUnrequiredOption<CombinatorSchema<number>, R>Create an integer argument schema with optional range validation.
Only accepts integer values (no decimals).
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 | IntegerOptions & { required?: R } | Range options. (optional) |
Returns
WithUnrequiredOption<CombinatorSchema<number>, R> — A combinator schema that resolves to number (integer).
Examples
ts
const args = {
retries: integer({ min: 0, max: 10 })
}Call Signature
ts
export declare function integer(opts?: IntegerOptions): CombinatorSchema<number>Create an integer argument schema with optional range validation.
Only accepts integer values (no decimals).
Parameters
| Name | Type | Description |
|---|---|---|
opts | IntegerOptions | Range options. (optional) |
Returns
CombinatorSchema<number> — A combinator schema that resolves to number (integer).
Examples
ts
const args = {
retries: integer({ min: 0, max: 10 })
}