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
Name | Type | Optional | Description |
---|---|---|---|
input | any | No | Input to validate. |
rangeLower | number | Yes | Optional parameter which specifies the lower range. |
rangeUpper | number | Yes | Optional parameter which specifies the upper range. |
Return value
Returns true
if the input is a floating point number.
Example
import { isFloat } from "@tripetto/builder";
isFloat(1.01); // Returns `true`
isFloat(1); // Returns `false`
isFloat(Infinity); // Returns `false`
isFloat(NaN); // Returns `false`
isFloat("1"); // Returns `false`