Skip to content

Latest commit

 

History

History
38 lines (26 loc) · 707 Bytes

README.md

File metadata and controls

38 lines (26 loc) · 707 Bytes

js-decval

Simple JavaScript decimal number validator.

Currently the decimal separator is a period (.).

Usage

validate(numberString[, maxIntegralCount[, fractionalCount]])

Examples

The function retuns a boolean, in the following cases a true. In the following example the library has been required using Node.js's syntax:

var decval = require('../index');
var ok = decval.validate('123.4');
var ok = decval.validate('123.45');
var ok = decval.validate('123.45', 3);
var ok = decval.validate('123.45', 3, 2);

Running tests

Prerequisites: Node.js (including npm)

Install dependencies:

npm install

And run tests:

make test