-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib: improve validation utils and refactor vm argument validation #31480
Conversation
Add common validators: `validateArray`, `validateBoolean`, `validateObject` and appropriate tests.
} | ||
return {}; | ||
return contextOptions; | ||
} | ||
|
||
function isContext(object) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not changed as currently, it skips Arrays to the _isContext
function which in turn rejects them. If I use validateObject
it would change the error message for Arrays passed to the isContext
from expected to be vm.Context
to expected to be an Object
and since we have explicit tests for this case I decided to not change this for now.
ping @nodejs/vm @BridgeAR (I guess there is no proper group for this one too). |
Started another CI to make sure everything is fine, the previous one is quite old. |
Add common validators: `validateArray`, `validateBoolean`, `validateObject` and appropriate tests. PR-URL: #31480 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
PR-URL: #31480 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
@lundibundi does this need to be backported to v13.x? it'll need manual if so. |
PR-URL: #31480 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
was able to get this backported... must have been some new changes that landed that made this work. removing label |
Add common validators: `validateArray`, `validateBoolean`, `validateObject` and appropriate tests. PR-URL: #31480 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
The first commit adds basic validation utilities like
validateArray
,validateBoolean
,validateObject
.The second commit refactors
vm.js
with the new validators as an example. There are multiple places in the codebase where we manually validate objects and arrays which can be simplified withvalidators.js
.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes//cc @nodejs/vm