Comparing version 1.0.1 to 1.0.2
@@ -20,3 +20,3 @@ /** | ||
*/ | ||
module.exports = function _validateRecursive (expected, actual, errors, ensureSerializable){ | ||
module.exports = function _validateRecursive (expected, actual, errors, ensureSerializable, meta){ | ||
@@ -116,6 +116,15 @@ // Look up expected type from `types` object using `expected`. | ||
errors.push((function (){ | ||
var err = new Error(util.format( | ||
var msg = util.format( | ||
'An invalid value was specified: \n' + util.inspect(actual, false, null) + '\n\n' + | ||
'This doesn\'t match the specified type: \n' + util.inspect(expected, false, null) | ||
)); | ||
); | ||
if (meta && meta.keyName) { | ||
msg = "For key `"+meta.keyName+"`: " + msg; | ||
} | ||
var err = new Error(msg); | ||
if (meta && meta.keyName) { | ||
err.inputKey = meta.keyName; | ||
} | ||
err.actual = util.inspect(actual, false, null); | ||
err.expected = util.inspect(expected, false, null); | ||
err.code = 'E_INVALID_TYPE'; | ||
@@ -154,6 +163,15 @@ | ||
errors.push((function (){ | ||
var err = new Error(util.format( | ||
var msg = util.format( | ||
'An invalid value was specified: \n' + util.inspect(actual, false, null) + '\n\n' + | ||
'This doesn\'t match the specified type: \n' + util.inspect(expected, false, null) | ||
)); | ||
); | ||
if (meta && meta.keyName) { | ||
msg = "For key `"+meta.keyName+"`: " + msg; | ||
} | ||
var err = new Error(msg); | ||
if (meta && meta.keyName) { | ||
err.inputKey = meta.keyName; | ||
} | ||
err.actual = util.inspect(actual, false, null); | ||
err.expected = util.inspect(expected, false, null); | ||
err.code = 'E_INVALID_TYPE'; | ||
@@ -181,6 +199,15 @@ | ||
errors.push((function (){ | ||
var err = new Error(util.format( | ||
var msg = util.format( | ||
'An invalid value was specified: \n' + util.inspect(actual, false, null) + '\n\n' + | ||
'This cannot be coerced into the specified type: \n' + util.inspect(expected, false, null) | ||
)); | ||
); | ||
if (meta && meta.keyName) { | ||
msg = "For key `"+meta.keyName+"`: " + msg; | ||
} | ||
var err = new Error(msg); | ||
if (meta && meta.keyName) { | ||
err.inputKey = meta.keyName; | ||
} | ||
err.actual = util.inspect(actual, false, null); | ||
err.expected = util.inspect(expected, false, null); | ||
err.code = 'E_COERCION'; | ||
@@ -220,3 +247,4 @@ return err; | ||
return _.reduce(expected, function (memo, expectedVal, expectedKey) { | ||
memo[expectedKey] = _validateRecursive(expected[expectedKey], coercedValue[expectedKey], errors, ensureSerializable); | ||
var keyName = (meta && meta.keyName ? (meta.keyName + ".") : "") + expectedKey; | ||
memo[expectedKey] = _validateRecursive(expected[expectedKey], coercedValue[expectedKey], errors, ensureSerializable, {keyName: keyName}); | ||
return memo; | ||
@@ -223,0 +251,0 @@ }, {}); |
{ | ||
"name": "rttc", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Runtime type-checking for JavaScript.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23237
559
1