Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rttc

Package Overview
Dependencies
Maintainers
4
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rttc - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

44

lib/helpers/validate-recursive.js

@@ -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 @@ }, {});

2

package.json
{
"name": "rttc",
"version": "1.0.1",
"version": "1.0.2",
"description": "Runtime type-checking for JavaScript.",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc