Skip to main content

isFloat

Validates if the supplied input is a floating point number and optionally checks if the number is within the specified range.

Signature

isFloat(input: any, rangeLower?: number, rangeUpper?: number): boolean

Parameters

NameTypeOptionalDescription
inputanyNoInput to validate.
rangeLowernumberYesOptional parameter which specifies the lower range.
rangeUppernumberYesOptional parameter which specifies the upper range.

Return value

Returns true if the input is a floating point number.

Example

import { isFloat } from "@tripetto/runner";

isFloat(1.01); // Returns `true`
isFloat(1); // Returns `false`
isFloat(Infinity); // Returns `false`
isFloat(NaN); // Returns `false`
isFloat("1"); // Returns `false`