GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — lib: support ranges in validateInt32() · nodejs/node@36e5100

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal
    • validators.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/validators.js‎

Copy file name to clipboardExpand all lines: lib/internal/validators.js
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,22 @@ function validateInteger(value, name) {
6363
}
6464

6565
function validateInt32(value, name, min = -2147483648, max = 2147483647) {
66+
// The defaults for min and max correspond to the limits of 32-bit integers.
6667
if (!isInt32(value)) {
6768
let err;
6869
if (typeof value !== 'number') {
6970
err = new ERR_INVALID_ARG_TYPE(name, 'number', value);
7071
} else if (!Number.isInteger(value)) {
7172
err = new ERR_OUT_OF_RANGE(name, 'an integer', value);
7273
} else {
73-
// 2 ** 31 === 2147483648
74-
err = new ERR_OUT_OF_RANGE(name, '> -2147483649 && < 2147483648', value);
74+
err = new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value);
7575
}
7676
Error.captureStackTrace(err, validateInt32);
7777
throw err;
78+
} else if (value < min || value > max) {
79+
const err = new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value);
80+
Error.captureStackTrace(err, validateInt32);
81+
throw err;
7882
}
7983
}
8084

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.