validate-number
v0.0.1
Published
Strip any extranous price characters such as $ and make sure there is still a valid number
Readme
Validate Number
Strip any extranous price characters such as $ and make sure there is still a valid number
Installation
npm install -S validate-numberUsage
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)