Skip to content

Commit

Permalink
Merge pull request #810 from AmirSasson/master
Browse files Browse the repository at this point in the history
isNumeric to support floating points
  • Loading branch information
chriso authored May 3, 2018
2 parents 92ed4d0 + 9e1f629 commit 02d31d2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/isNumeric.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var _assertString2 = _interopRequireDefault(_assertString);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

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

function isNumeric(str) {
(0, _assertString2.default)(str);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/isNumeric.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assertString from './util/assertString';

const numeric = /^[-+]?[0-9]+$/;
const numeric = /^[+-]?([0-9]*[.])?[0-9]+$/;

export default function isNumeric(str) {
assertString(str);
Expand Down
16 changes: 8 additions & 8 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -1463,9 +1463,9 @@ describe('Validators', function () {
'0',
'-0',
'+123',
'123.123',
],
invalid: [
'123.123',
' ',
'.',
],
Expand Down Expand Up @@ -2960,12 +2960,12 @@ describe('Validators', function () {
'Vml2YW11cyBmZXJtZW50dW0gc2VtcGVyIHBvcnRhLg==',
'U3VzcGVuZGlzc2UgbGVjdHVzIGxlbw==',
'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuMPNS1Ufof9EW/M98FNw' +
'UAKrwflsqVxaxQjBQnHQmiI7Vac40t8x7pIb8gLGV6wL7sBTJiPovJ0V7y7oc0Ye' +
'rhKh0Rm4skP2z/jHwwZICgGzBvA0rH8xlhUiTvcwDCJ0kc+fh35hNt8srZQM4619' +
'FTgB66Xmp4EtVyhpQV+t02g6NzK72oZI0vnAvqhpkxLeLiMCyrI416wHm5Tkukhx' +
'QmcL2a6hNOyu0ixX/x2kSFXApEnVrJ+/IxGyfyw8kf4N2IZpW5nEP847lpfj0SZZ' +
'Fwrd1mnfnDbYohX2zRptLy2ZUn06Qo9pkG5ntvFEPo9bfZeULtjYzIl6K8gJ2uGZ' +
'HQIDAQAB',
'UAKrwflsqVxaxQjBQnHQmiI7Vac40t8x7pIb8gLGV6wL7sBTJiPovJ0V7y7oc0Ye' +
'rhKh0Rm4skP2z/jHwwZICgGzBvA0rH8xlhUiTvcwDCJ0kc+fh35hNt8srZQM4619' +
'FTgB66Xmp4EtVyhpQV+t02g6NzK72oZI0vnAvqhpkxLeLiMCyrI416wHm5Tkukhx' +
'QmcL2a6hNOyu0ixX/x2kSFXApEnVrJ+/IxGyfyw8kf4N2IZpW5nEP847lpfj0SZZ' +
'Fwrd1mnfnDbYohX2zRptLy2ZUn06Qo9pkG5ntvFEPo9bfZeULtjYzIl6K8gJ2uGZ' +
'HQIDAQAB',
],
invalid: [
'12345',
Expand Down Expand Up @@ -4136,7 +4136,7 @@ describe('Validators', function () {
test({
validator: 'isCurrency',
args: [
{ },
{},
'-$##,###.## (en-US, en-CA, en-AU, en-NZ, en-HK)',
],
valid: [
Expand Down
2 changes: 1 addition & 1 deletion validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ function isAlphanumeric(str) {
throw new Error('Invalid locale \'' + locale + '\'');
}

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

function isNumeric(str) {
assertString(str);
Expand Down
2 changes: 1 addition & 1 deletion validator.min.js

Large diffs are not rendered by default.

0 comments on commit 02d31d2

Please sign in to comment.