Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/lib/isInt.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ export default function isInt(str, options) {

// Get the regex to use for testing, based on whether
// leading zeroes are allowed or not.
let regex = (
options.hasOwnProperty('allow_leading_zeroes') && !options.allow_leading_zeroes ?
int : intLeadingZeroes
);
const regex = options.allow_leading_zeroes === false ? int : intLeadingZeroes;

// Check min/max/lt/gt
let minCheckPassed = (!options.hasOwnProperty('min') || str >= options.min);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/isPort.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import isInt from './isInt';

export default function isPort(str) {
return isInt(str, { min: 0, max: 65535 });
return isInt(str, { allow_leading_zeroes: false, min: 0, max: 65535 });
}
1 change: 1 addition & 0 deletions test/validators.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2797,6 +2797,7 @@ describe('Validators', () => {
'',
'-1',
'65536',
'0080',
],
});
});
Expand Down