Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/nisaacson/validate-number
- Owner: nisaacson
- Created: 2013-06-14T15:42:09.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-06-14T15:46:56.000Z (over 11 years ago)
- Last Synced: 2024-10-08T17:28:09.061Z (about 1 month ago)
- Language: JavaScript
- Size: 105 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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)
```