Skip to content

Commit

Permalink
IsNumeric to support floats
Browse files Browse the repository at this point in the history
  • Loading branch information
AmirSasson committed Apr 22, 2018
1 parent 8ba0c29 commit 8944b70
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 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 @@ -1460,9 +1460,9 @@ describe('Validators', function () {
'0',
'-0',
'+123',
'123.123',
],
invalid: [
'123.123',
' ',
'.',
],
Expand Down Expand Up @@ -2957,12 +2957,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 @@ -4133,7 +4133,7 @@ describe('Validators', function () {
test({
validator: 'isCurrency',
args: [
{ },
{},
'-$##,###.## (en-US, en-CA, en-AU, en-NZ, en-HK)',
],
valid: [
Expand Down
Loading

0 comments on commit 8944b70

Please sign in to comment.