1.19.0 • Published 4 months ago
is-positive-int v1.19.0
is-positive-int
Validate if a value is a positive integer between 0 & maximum safe integer in JavaScript
Install
npm install is-positive-int
Usage
import isPositiveInt from 'is-positive-int';
// Test cases
// Valid positive values
isPositiveInt(0); // true
isPositiveInt(1); // true
isPositiveInt(5034); // true
isPositiveInt(Math.pow(2, 53) - 1); // true
isPositiveInt(Number.MAX_SAFE_INTEGER); // true
isPositiveInt(1.0); // true
isPositiveInt(5e2); // true, 500 in exponential notation
isPositiveInt(9.007199254740991e15); // true, Number.MAX_SAFE_INTEGER.toExponential()
// Invalid values
isPositiveInt(-5034); // false
isPositiveInt(-Math.pow(2, 53) - 1); // false
isPositiveInt(-Number.MAX_SAFE_INTEGER); // false
isPositiveInt(Number.MIN_SAFE_INTEGER); // false
isPositiveInt(1.1); // false
isPositiveInt(-5e2); // false
isPositiveInt(NaN); // false
isPositiveInt(Infinity); // false
isPositiveInt(-Infinity); // false
isPositiveInt(null); // false
isPositiveInt(undefined); // false
isPositiveInt(Math.pow(2, 53)); // false
isPositiveInt(-Math.pow(2, 53)); // false
isPositiveInt(Number.MAX_SAFE_INTEGER + 1); // false
isPositiveInt(-Number.MAX_SAFE_INTEGER - 1);// false
isPositiveInt(Number.MIN_SAFE_INTEGER - 1); // false
isPositiveInt(Math.PI); // false
isPositiveInt(-9.007199254740991e15); // false
isPositiveInt(9.007199254740991e15 + 1); // false
isPositiveInt('10'); // false
isPositiveInt(true); // false
isPositiveInt(false); // false
isPositiveInt([1]); // false
isPositiveInt({}); // false
License
MIT © Palash Mondal
1.19.0
4 months ago
1.18.0
5 months ago
1.17.0
7 months ago
1.16.0
8 months ago
1.15.0
9 months ago
1.13.0
11 months ago
1.12.0
12 months ago
1.9.0
1 year ago
1.8.0
1 year ago
1.7.0
1 year ago
1.11.0
12 months ago
1.10.0
1 year ago
1.6.0
1 year ago
1.5.0
1 year ago
1.3.0
1 year ago
1.1.0
1 year ago
1.0.5
1 year ago
1.0.4
1 year ago
1.0.3
1 year ago
1.0.2
7 years ago
1.0.1
8 years ago
1.0.0
8 years ago