validate-number

0.0.1 • Public • Published

Validate Number

Strip any extranous price characters such as $ and make sure there is still a valid number

Installation

npm install -S validate-number

Usage

When using with a valid number, you will get the number back without any extra characters

var validateNumber = require('validateNumber')
var extract = '-$1.99'
var price = validateNumber(extract)
console.log('price %s', price)

When using with a invalid number, you will get back null

var validateNumber = require('validateNumber')
var extract = '-$foobar'
var price = validateNumber(extract) // price will be null
console.log('price %s', price)

Readme

Keywords

none

Package Sidebar

Install

npm i validate-number

Weekly Downloads

2

Version

0.0.1

License

BSD

Last publish

Collaborators

  • clewfirst