Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nisaacson/validate-number

Strip any extranous price characters such as `$` and make sure there is still a valid number
https://github.com/nisaacson/validate-number

Last synced: about 1 month ago
JSON representation

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

Awesome Lists containing this project

README

        

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

# Installation

```bash
npm install -S validate-number
```

# Usage

When using with a valid number, you will get the number back without any extra characters
```javascript
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
```javascript
var validateNumber = require('validateNumber')
var extract = '-$foobar'
var price = validateNumber(extract) // price will be null
console.log('price %s', price)
```