Function: float()
Call Signature
ts
export declare function float<const R extends boolean>(opts: FloatOptions & {
required: R;
}): WithRequiredOption<CombinatorSchema<number>, R>Create a floating-point argument schema with optional range validation.
Rejects NaN and Infinity values.
Type Parameters
| Name | Description |
|---|---|
R extends boolean | The type of required in the options, which the schema keeps. |
Parameters
| Name | Type | Description |
|---|---|---|
opts | FloatOptions & { required: R } | Range options. |
Returns
WithRequiredOption<CombinatorSchema<number>, R> — A combinator schema that resolves to number (float).
Examples
ts
const args = {
ratio: float({ min: 0, max: 1 })
}Call Signature
ts
export declare function float<const R extends boolean | undefined = boolean | undefined>(opts?: FloatOptions & {
required?: R;
}): WithUnrequiredOption<CombinatorSchema<number>, R>Create a floating-point argument schema with optional range validation.
Rejects NaN and Infinity values.
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 | FloatOptions & { required?: R } | Range options. (optional) |
Returns
WithUnrequiredOption<CombinatorSchema<number>, R> — A combinator schema that resolves to number (float).
Examples
ts
const args = {
ratio: float({ min: 0, max: 1 })
}Call Signature
ts
export declare function float(opts?: FloatOptions): CombinatorSchema<number>Create a floating-point argument schema with optional range validation.
Rejects NaN and Infinity values.
Parameters
| Name | Type | Description |
|---|---|---|
opts | FloatOptions | Range options. (optional) |
Returns
CombinatorSchema<number> — A combinator schema that resolves to number (float).
Examples
ts
const args = {
ratio: float({ min: 0, max: 1 })
}