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: 4 months 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 (about 12 years ago)
- Default Branch: master
- Last Pushed: 2013-06-14T15:46:56.000Z (about 12 years ago)
- Last Synced: 2025-03-01T00:18:05.385Z (4 months 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)
```