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

isNumeric to support floating points #810

Merged
merged 3 commits into from May 3, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion validator.js
Expand Up @@ -546,7 +546,7 @@ function isAlphanumeric(str) {
throw new Error('Invalid locale \'' + locale + '\'');
}

var numeric = /^[-+]?[0-9]+$/;
var numeric = /^[+-]?([0-9]*[.])?[0-9]+$/;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Amir. The regex looks like it should do the trick but unfortunately it's been implemented directly into the built version of validator.js. You'll want to implement it in the isNumeric source file, update the tests, and run the build and commit any changes.

The source file is this one: https://github.com/chriso/validator.js/blob/master/src/lib/isNumeric.js

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pietvanzoen , done


function isNumeric(str) {
assertString(str);
Expand Down