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

vm: reuse validateString of internal/validators #25074

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
8 participants
@ZYSzys
Copy link
Member

ZYSzys commented Dec 16, 2018

The validateString function in vm.js is just one more judgement which validates whether prop !== undefined than the validateString function in internal/validators:

node/lib/vm.js

Lines 153 to 156 in 8f4b924

function validateString(prop, propName) {
if (prop !== undefined && typeof prop !== 'string')
throw new ERR_INVALID_ARG_TYPE(propName, 'string', prop);
}

function validateString(value, name) {
if (typeof value !== 'string')
throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
}

So now just reuse the general validateString in validator.js totally.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
@targos

targos approved these changes Dec 16, 2018

@antsmartian
Copy link
Contributor

antsmartian left a comment

LGTM

@antsmartian

This comment has been minimized.

Copy link
Contributor

antsmartian commented Dec 16, 2018

@lpinca

lpinca approved these changes Dec 16, 2018

@danbev

This comment has been minimized.

Copy link
Member

danbev commented Dec 20, 2018

Landed in e5966ef.

@danbev danbev closed this Dec 20, 2018

danbev added a commit that referenced this pull request Dec 20, 2018

vm: reuse validateString of internal/validators
PR-URL: #25074
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>

@ZYSzys ZYSzys deleted the zys-contribs:validate-string-vm branch Dec 20, 2018

MylesBorins added a commit that referenced this pull request Dec 25, 2018

vm: reuse validateString of internal/validators
PR-URL: #25074
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>

@MylesBorins MylesBorins referenced this pull request Dec 25, 2018

Merged

v11.6.0 proposal #25175

MylesBorins added a commit that referenced this pull request Dec 26, 2018

vm: reuse validateString of internal/validators
PR-URL: #25074
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>

refack added a commit to refack/node that referenced this pull request Jan 14, 2019

vm: reuse validateString of internal/validators
PR-URL: nodejs#25074
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment