Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validating a number #58

Closed
stephanstapel opened this issue Apr 12, 2013 · 3 comments
Closed

Validating a number #58

stephanstapel opened this issue Apr 12, 2013 · 3 comments

Comments

@stephanstapel
Copy link

It would be great if numeraljs would allow to validate a given string to be a number (or not).

I was wondering if this would be possible by using a similar approach like unformat(), removing thousand separator, the abbreviations first, then taking the result of

string.replace(/[^0-9.-]+/g, '')

and determining if the length is different to the length of the source string (--> check if the string contained invalid characters).

What do you think?

@adamwdraper
Copy link
Owner

interesting idea. i'll look into this.

@zeusdeux
Copy link
Contributor

zeusdeux commented Mar 7, 2014

I have created a pull request (issue #146) that adds a top level validate method that can be used as
numeral.validate(value [, language])

@adamwdraper
Copy link
Owner

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants