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

Support numerals the way JSON spec defines them #118

Closed
kosty opened this issue Feb 21, 2019 · 3 comments
Closed

Support numerals the way JSON spec defines them #118

kosty opened this issue Feb 21, 2019 · 3 comments
Labels

Comments

@kosty
Copy link
Contributor

kosty commented Feb 21, 2019

Currently TypeValidator has a loose mode (which is great) but isInteger and isNumeric do not fully comply with numeric literals defined by JSON spec. In particular the following values are not regarded as numbers by JSON (some of them are successfully validated by TypeValidator)

"01.1", "1.", ".1", "E1", "E+1", "E-1", ".E1", ".E+1", ".E-1", ".1E1", ".1E+1", ".1E-1", "+1"

also the following values are all valid numbers as per spec

"1", "-1", "1.1", "-1.1", "0E+1", "0E-1", "0E1", "-0E+1", "-0E-1", "-0E1", "0.1E+1", "0.1E-1", "0.1E1", "-0.1E+1", "-0.1E-1", "-0.1E1", "10.1", "-10.1", "10E+1", "10E-1", "10E1", "-10E+1", "-10E-1", "-10E1", "10.1E+1", "10.1E-1", "10.1E1", "-10.1E+1", "-10.1E-1", "-10.1E1" 

Note
+1, 0001 is currently successfully validated by TypeValidator adhering to spec might introduce breaking change for some of existing users

@kosty
Copy link
Contributor Author

kosty commented Feb 21, 2019

@stevehu please treat this PR as a proposal/starting point. Let's figure out which direction to take it.

@stevehu
Copy link
Contributor

stevehu commented Feb 21, 2019

For sure. I have already invited other members who are familiar with the project to review. We can discuss in the PR. I am glad that you have included unit tests to make the usage very clear. Thanks.

@kosty
Copy link
Contributor Author

kosty commented Mar 24, 2019

Just realized, this was not closed after merge. Closing

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

No branches or pull requests

2 participants