From d80082f3eb1b19897f93a98335bfa4f9ded9f9f0 Mon Sep 17 00:00:00 2001 From: Voltrex Date: Wed, 25 Aug 2021 02:55:58 +0430 Subject: [PATCH] crypto: use `validateObject` The `validateObject()` validator can be used to cleanup validation and keep consistency. PR-URL: https://github.com/nodejs/node/pull/39872 Reviewed-By: Zijian Liu Reviewed-By: Khaidi Chu Reviewed-By: James M Snell --- lib/internal/crypto/keys.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/internal/crypto/keys.js b/lib/internal/crypto/keys.js index 4d5545ab1aae1a..ce053fbb4b800a 100644 --- a/lib/internal/crypto/keys.js +++ b/lib/internal/crypto/keys.js @@ -299,8 +299,7 @@ function isStringOrBuffer(val) { } function parseKeyEncoding(enc, keyType, isPublic, objName) { - if (enc === null || typeof enc !== 'object') - throw new ERR_INVALID_ARG_TYPE('options', 'object', enc); + validateObject(enc, 'options'); const isInput = keyType === undefined;