Skip to content

Commit 8c4b8b2

Browse files
VoltrexKeyvajasnell
authored andcommitted
lib: replace validator and error
Refs: #41660 PR-URL: #41678 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 217acb9 commit 8c4b8b2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+646
-177
lines changed

doc/api/crypto.md

+65
Original file line numberDiff line numberDiff line change
@@ -2869,6 +2869,12 @@ This property is deprecated. Please use `crypto.setFips()` and
28692869

28702870
<!-- YAML
28712871
added: v15.8.0
2872+
changes:
2873+
- version: REPLACEME
2874+
pr-url: https://github.com/nodejs/node/pull/41678
2875+
description: Passing an invalid callback to the `callback` argument
2876+
now throws `ERR_INVALID_ARG_TYPE` instead of
2877+
`ERR_INVALID_CALLBACK`.
28722878
-->
28732879

28742880
* `candidate` {ArrayBuffer|SharedArrayBuffer|TypedArray|Buffer|DataView|bigint}
@@ -3547,6 +3553,12 @@ Both keys must have the same `asymmetricKeyType`, which must be one of `'dh'`
35473553

35483554
<!-- YAML
35493555
added: v15.0.0
3556+
changes:
3557+
- version: REPLACEME
3558+
pr-url: https://github.com/nodejs/node/pull/41678
3559+
description: Passing an invalid callback to the `callback` argument
3560+
now throws `ERR_INVALID_ARG_TYPE` instead of
3561+
`ERR_INVALID_CALLBACK`.
35503562
-->
35513563

35523564
* `type`: {string} The intended use of the generated secret key. Currently
@@ -3592,6 +3604,11 @@ generateKey('hmac', { length: 64 }, (err, key) => {
35923604
<!-- YAML
35933605
added: v10.12.0
35943606
changes:
3607+
- version: REPLACEME
3608+
pr-url: https://github.com/nodejs/node/pull/41678
3609+
description: Passing an invalid callback to the `callback` argument
3610+
now throws `ERR_INVALID_ARG_TYPE` instead of
3611+
`ERR_INVALID_CALLBACK`.
35953612
- version: v16.10.0
35963613
pr-url: https://github.com/nodejs/node/pull/39927
35973614
description: Add ability to define `RSASSA-PSS-params` sequence parameters
@@ -3852,6 +3869,12 @@ console.log(key.export().toString('hex')); // e89..........41e
38523869

38533870
<!-- YAML
38543871
added: v15.8.0
3872+
changes:
3873+
- version: REPLACEME
3874+
pr-url: https://github.com/nodejs/node/pull/41678
3875+
description: Passing an invalid callback to the `callback` argument
3876+
now throws `ERR_INVALID_ARG_TYPE` instead of
3877+
`ERR_INVALID_CALLBACK`.
38553878
-->
38563879

38573880
* `size` {number} The size (in bits) of the prime to generate.
@@ -4118,6 +4141,12 @@ A convenient alias for [`crypto.webcrypto.getRandomValues()`][].
41184141

41194142
<!-- YAML
41204143
added: v15.0.0
4144+
changes:
4145+
- version: REPLACEME
4146+
pr-url: https://github.com/nodejs/node/pull/41678
4147+
description: Passing an invalid callback to the `callback` argument
4148+
now throws `ERR_INVALID_ARG_TYPE` instead of
4149+
`ERR_INVALID_CALLBACK`.
41214150
-->
41224151

41234152
* `digest` {string} The digest algorithm to use.
@@ -4221,6 +4250,11 @@ console.log(Buffer.from(derivedKey).toString('hex')); // '24156e2...5391653'
42214250
<!-- YAML
42224251
added: v0.5.5
42234252
changes:
4253+
- version: REPLACEME
4254+
pr-url: https://github.com/nodejs/node/pull/41678
4255+
description: Passing an invalid callback to the `callback` argument
4256+
now throws `ERR_INVALID_ARG_TYPE` instead of
4257+
`ERR_INVALID_CALLBACK`.
42244258
- version: v15.0.0
42254259
pr-url: https://github.com/nodejs/node/pull/35093
42264260
description: The password and salt arguments can also be ArrayBuffer
@@ -4602,6 +4636,11 @@ be passed instead of a public key.
46024636
<!-- YAML
46034637
added: v0.5.8
46044638
changes:
4639+
- version: REPLACEME
4640+
pr-url: https://github.com/nodejs/node/pull/41678
4641+
description: Passing an invalid callback to the `callback` argument
4642+
now throws `ERR_INVALID_ARG_TYPE` instead of
4643+
`ERR_INVALID_CALLBACK`.
46054644
- version: v9.0.0
46064645
pr-url: https://github.com/nodejs/node/pull/16454
46074646
description: Passing `null` as the `callback` argument now throws
@@ -4782,6 +4821,11 @@ added:
47824821
- v7.10.0
47834822
- v6.13.0
47844823
changes:
4824+
- version: REPLACEME
4825+
pr-url: https://github.com/nodejs/node/pull/41678
4826+
description: Passing an invalid callback to the `callback` argument
4827+
now throws `ERR_INVALID_ARG_TYPE` instead of
4828+
`ERR_INVALID_CALLBACK`.
47854829
- version: v9.0.0
47864830
pr-url: https://github.com/nodejs/node/pull/15231
47874831
description: The `buffer` argument may be any `TypedArray` or `DataView`.
@@ -4918,6 +4962,12 @@ request.
49184962
added:
49194963
- v14.10.0
49204964
- v12.19.0
4965+
changes:
4966+
- version: REPLACEME
4967+
pr-url: https://github.com/nodejs/node/pull/41678
4968+
description: Passing an invalid callback to the `callback` argument
4969+
now throws `ERR_INVALID_ARG_TYPE` instead of
4970+
`ERR_INVALID_CALLBACK`.
49214971
-->
49224972

49234973
* `min` {integer} Start of random range (inclusive). **Default:** `0`.
@@ -5021,6 +5071,11 @@ cryptographic pseudorandom number generator.
50215071
<!-- YAML
50225072
added: v10.5.0
50235073
changes:
5074+
- version: REPLACEME
5075+
pr-url: https://github.com/nodejs/node/pull/41678
5076+
description: Passing an invalid callback to the `callback` argument
5077+
now throws `ERR_INVALID_ARG_TYPE` instead of
5078+
`ERR_INVALID_CALLBACK`.
50245079
- version: v15.0.0
50255080
pr-url: https://github.com/nodejs/node/pull/35093
50265081
description: The password and salt arguments can also be ArrayBuffer
@@ -5244,6 +5299,11 @@ Throws an error if FIPS mode is not available.
52445299
<!-- YAML
52455300
added: v12.0.0
52465301
changes:
5302+
- version: REPLACEME
5303+
pr-url: https://github.com/nodejs/node/pull/41678
5304+
description: Passing an invalid callback to the `callback` argument
5305+
now throws `ERR_INVALID_ARG_TYPE` instead of
5306+
`ERR_INVALID_CALLBACK`.
52475307
- version: v15.12.0
52485308
pr-url: https://github.com/nodejs/node/pull/37500
52495309
description: Optional callback argument added.
@@ -5340,6 +5400,11 @@ not introduce timing vulnerabilities.
53405400
<!-- YAML
53415401
added: v12.0.0
53425402
changes:
5403+
- version: REPLACEME
5404+
pr-url: https://github.com/nodejs/node/pull/41678
5405+
description: Passing an invalid callback to the `callback` argument
5406+
now throws `ERR_INVALID_ARG_TYPE` instead of
5407+
`ERR_INVALID_CALLBACK`.
53435408
- version: v15.12.0
53445409
pr-url: https://github.com/nodejs/node/pull/37500
53455410
description: Optional callback argument added.

doc/api/deprecations.md

+14
Original file line numberDiff line numberDiff line change
@@ -3056,6 +3056,20 @@ This method was deprecated because it is not compatible with
30563056

30573057
Use [`buffer.subarray`][] which does the same thing instead.
30583058

3059+
### DEP0159: `ERR_INVALID_CALLBACK`
3060+
3061+
<!-- YAML
3062+
changes:
3063+
- version: REPLACEME
3064+
pr-url: https://github.com/nodejs/node/pull/41678
3065+
description: End-of-Life.
3066+
-->
3067+
3068+
Type: End-of-Life
3069+
3070+
This error code was removed due to adding more confusion to
3071+
the errors used for value type validation.
3072+
30593073
[Legacy URL API]: url.md#legacy-url-api
30603074
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
30613075
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3

doc/api/dns.md

+90
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ section if a custom port is used.
179179
<!-- YAML
180180
added: v0.1.90
181181
changes:
182+
- version: REPLACEME
183+
pr-url: https://github.com/nodejs/node/pull/41678
184+
description: Passing an invalid callback to the `callback` argument
185+
now throws `ERR_INVALID_ARG_TYPE` instead of
186+
`ERR_INVALID_CALLBACK`.
182187
- version: v17.0.0
183188
pr-url: https://github.com/nodejs/node/pull/39987
184189
description: The `verbatim` options defaults to `true` now.
@@ -282,6 +287,12 @@ The following flags can be passed as hints to [`dns.lookup()`][].
282287

283288
<!-- YAML
284289
added: v0.11.14
290+
changes:
291+
- version: REPLACEME
292+
pr-url: https://github.com/nodejs/node/pull/41678
293+
description: Passing an invalid callback to the `callback` argument
294+
now throws `ERR_INVALID_ARG_TYPE` instead of
295+
`ERR_INVALID_CALLBACK`.
285296
-->
286297

287298
* `address` {string}
@@ -315,6 +326,12 @@ If this method is invoked as its [`util.promisify()`][]ed version, it returns a
315326

316327
<!-- YAML
317328
added: v0.1.27
329+
changes:
330+
- version: REPLACEME
331+
pr-url: https://github.com/nodejs/node/pull/41678
332+
description: Passing an invalid callback to the `callback` argument
333+
now throws `ERR_INVALID_ARG_TYPE` instead of
334+
`ERR_INVALID_CALLBACK`.
318335
-->
319336

320337
* `hostname` {string} Host name to resolve.
@@ -351,6 +368,11 @@ On error, `err` is an [`Error`][] object, where `err.code` is one of the
351368
<!-- YAML
352369
added: v0.1.16
353370
changes:
371+
- version: REPLACEME
372+
pr-url: https://github.com/nodejs/node/pull/41678
373+
description: Passing an invalid callback to the `callback` argument
374+
now throws `ERR_INVALID_ARG_TYPE` instead of
375+
`ERR_INVALID_CALLBACK`.
354376
- version: v7.2.0
355377
pr-url: https://github.com/nodejs/node/pull/9296
356378
description: This method now supports passing `options`,
@@ -377,6 +399,11 @@ will contain an array of IPv4 addresses (e.g.
377399
<!-- YAML
378400
added: v0.1.16
379401
changes:
402+
- version: REPLACEME
403+
pr-url: https://github.com/nodejs/node/pull/41678
404+
description: Passing an invalid callback to the `callback` argument
405+
now throws `ERR_INVALID_ARG_TYPE` instead of
406+
`ERR_INVALID_CALLBACK`.
380407
- version: v7.2.0
381408
pr-url: https://github.com/nodejs/node/pull/9296
382409
description: This method now supports passing `options`,
@@ -399,6 +426,15 @@ will contain an array of IPv6 addresses.
399426

400427
## `dns.resolveAny(hostname, callback)`
401428

429+
<!-- YAML
430+
changes:
431+
- version: REPLACEME
432+
pr-url: https://github.com/nodejs/node/pull/41678
433+
description: Passing an invalid callback to the `callback` argument
434+
now throws `ERR_INVALID_ARG_TYPE` instead of
435+
`ERR_INVALID_CALLBACK`.
436+
-->
437+
402438
* `hostname` {string}
403439
* `callback` {Function}
404440
* `err` {Error}
@@ -451,6 +487,12 @@ queries. It may be better to call individual methods like [`dns.resolve4()`][],
451487

452488
<!-- YAML
453489
added: v0.3.2
490+
changes:
491+
- version: REPLACEME
492+
pr-url: https://github.com/nodejs/node/pull/41678
493+
description: Passing an invalid callback to the `callback` argument
494+
now throws `ERR_INVALID_ARG_TYPE` instead of
495+
`ERR_INVALID_CALLBACK`.
454496
-->
455497

456498
* `hostname` {string}
@@ -469,6 +511,12 @@ will contain an array of canonical name records available for the `hostname`
469511
added:
470512
- v15.0.0
471513
- v14.17.0
514+
changes:
515+
- version: REPLACEME
516+
pr-url: https://github.com/nodejs/node/pull/41678
517+
description: Passing an invalid callback to the `callback` argument
518+
now throws `ERR_INVALID_ARG_TYPE` instead of
519+
`ERR_INVALID_CALLBACK`.
472520
-->
473521

474522
* `hostname` {string}
@@ -486,6 +534,12 @@ available for the `hostname` (e.g. `[{critical: 0, iodef:
486534

487535
<!-- YAML
488536
added: v0.1.27
537+
changes:
538+
- version: REPLACEME
539+
pr-url: https://github.com/nodejs/node/pull/41678
540+
description: Passing an invalid callback to the `callback` argument
541+
now throws `ERR_INVALID_ARG_TYPE` instead of
542+
`ERR_INVALID_CALLBACK`.
489543
-->
490544

491545
* `hostname` {string}
@@ -502,6 +556,12 @@ property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`).
502556

503557
<!-- YAML
504558
added: v0.9.12
559+
changes:
560+
- version: REPLACEME
561+
pr-url: https://github.com/nodejs/node/pull/41678
562+
description: Passing an invalid callback to the `callback` argument
563+
now throws `ERR_INVALID_ARG_TYPE` instead of
564+
`ERR_INVALID_CALLBACK`.
505565
-->
506566

507567
* `hostname` {string}
@@ -537,6 +597,12 @@ function will contain an array of objects with the following properties:
537597

538598
<!-- YAML
539599
added: v0.1.90
600+
changes:
601+
- version: REPLACEME
602+
pr-url: https://github.com/nodejs/node/pull/41678
603+
description: Passing an invalid callback to the `callback` argument
604+
now throws `ERR_INVALID_ARG_TYPE` instead of
605+
`ERR_INVALID_CALLBACK`.
540606
-->
541607

542608
* `hostname` {string}
@@ -553,6 +619,12 @@ contain an array of name server records available for `hostname`
553619

554620
<!-- YAML
555621
added: v6.0.0
622+
changes:
623+
- version: REPLACEME
624+
pr-url: https://github.com/nodejs/node/pull/41678
625+
description: Passing an invalid callback to the `callback` argument
626+
now throws `ERR_INVALID_ARG_TYPE` instead of
627+
`ERR_INVALID_CALLBACK`.
556628
-->
557629

558630
* `hostname` {string}
@@ -568,6 +640,12 @@ be an array of strings containing the reply records.
568640

569641
<!-- YAML
570642
added: v0.11.10
643+
changes:
644+
- version: REPLACEME
645+
pr-url: https://github.com/nodejs/node/pull/41678
646+
description: Passing an invalid callback to the `callback` argument
647+
now throws `ERR_INVALID_ARG_TYPE` instead of
648+
`ERR_INVALID_CALLBACK`.
571649
-->
572650

573651
* `hostname` {string}
@@ -605,6 +683,12 @@ be an object with the following properties:
605683

606684
<!-- YAML
607685
added: v0.1.27
686+
changes:
687+
- version: REPLACEME
688+
pr-url: https://github.com/nodejs/node/pull/41678
689+
description: Passing an invalid callback to the `callback` argument
690+
now throws `ERR_INVALID_ARG_TYPE` instead of
691+
`ERR_INVALID_CALLBACK`.
608692
-->
609693

610694
* `hostname` {string}
@@ -636,6 +720,12 @@ be an array of objects with the following properties:
636720

637721
<!-- YAML
638722
added: v0.1.27
723+
changes:
724+
- version: REPLACEME
725+
pr-url: https://github.com/nodejs/node/pull/41678
726+
description: Passing an invalid callback to the `callback` argument
727+
now throws `ERR_INVALID_ARG_TYPE` instead of
728+
`ERR_INVALID_CALLBACK`.
639729
-->
640730

641731
<!--lint disable no-undefined-references list-item-bullet-indent-->

doc/api/errors.md

-6
Original file line numberDiff line numberDiff line change
@@ -1833,12 +1833,6 @@ less than -1 should never happen.
18331833
A swap was performed on a `Buffer` but its size was not compatible with the
18341834
operation.
18351835

1836-
<a id="ERR_INVALID_CALLBACK"></a>
1837-
1838-
### `ERR_INVALID_CALLBACK`
1839-
1840-
A callback function was required but was not been provided to a Node.js API.
1841-
18421836
<a id="ERR_INVALID_CHAR"></a>
18431837

18441838
### `ERR_INVALID_CHAR`

0 commit comments

Comments
 (0)