is-integer-string

0.0.2 • Public • Published

is-integer-string

Checks if a String Represents an Integer

Motivation

Design a library that is forgiving of user input and accepts the greatest amount of valid integers.

Features

  • Designed to accept all valid representations
  • Support for Numeric Separators and Commas!
  • Clear Explanations When a String Fails

install

npm install is-integer-string

usage

import isIntegerString from 'is-integer-string';

const result = isIntegerString('1_234.00');
// result is true

const result = isIntegerString('-0.3');
// result is false

advanced usage

Pass in an options object with debug set to true for increased logging

const options = { debug: true };
isIntegerString('1234.567', options);

This will generate the following output:

[is-integer-string] str: 1234.567
[is-integer-string] debug: true
[is-integer-string] parts: [ '1234', '567' ]
[is-integer-string] left: 1234
[is-integer-string] right: 567
[is-integer-string] the right side of the decimal contains invalid character(s): [ '5', '6', '7' ]

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i is-integer-string

      Weekly Downloads

      3

      Version

      0.0.2

      License

      CC0-1.0

      Unpacked Size

      11.2 kB

      Total Files

      4

      Last publish

      Collaborators

      • danieljdufour