openexchangerates / accounting.js

A lightweight JavaScript library for number, money and currency formatting - fully localisable, zero dependencies.
http://openexchangerates.github.io/accounting.js
MIT License
4.96k stars 530 forks source link

Add an IsValidNumber function #54

Open bmode opened 11 years ago

bmode commented 11 years ago

Hi, I love this library and it's been really helpful to me on a recent project. One suggestion: could you add a routine to determine if a string will be parsed correctly by "unformat". Something like "isValidNumber( string )". Alternatively, unformat could return null or undefined for invalid input instead of 0. I need to light up invalid text boxes in my application, so I need to be able to tell the difference between invalid and 0.

Thanks again for the really excellent library!

wizonesolutions commented 11 years ago

:+1:

bijanvakili commented 9 years ago

+1

Lakshmi-Sharma commented 8 years ago

This is the same as issue #98 and #51
Pull request #122 should fix this. Is takes in an 'invalid value' parameter.

accounting.unformat('what', ',' , null) = null