Comparing version 9.2.1 to 9.2.2
@@ -19,4 +19,15 @@ /** | ||
* | ||
* @param {*} schema | ||
* @return {{}} | ||
* | ||
* @param {*} schema - an exemplar or type schema | ||
* @param {String} path - a valid dot-deliminited path, where empty string ('') is the root (e.g. "" or "foo" or "foo.bar" or "foo.0.bar.0.baz") | ||
* | ||
* @returns {Dictionary} | ||
* @property {*} exemplar | ||
* @property {Boolean} optional | ||
* | ||
* @throws E_MALFORMED_PATH | ||
* If keypath is invalid for the provided schema | ||
* | ||
* @throws E_UNREACHABLE | ||
* if keypath is unreachable (meaning it is not allowed in the schema) | ||
*/ | ||
@@ -43,3 +54,7 @@ module.exports = function getPathInfo (schema, path) { | ||
// something funny is going on. | ||
throw new Error('Invalid keypath: "'+path+'" (non-numeric hop `'+hop+'` is not a valid array index)'); | ||
throw (function (){ | ||
var err = new Error('Malformed keypath: "'+path+'" (non-numeric hop `'+hop+'` is not a valid array index)'); | ||
err.code = 'E_MALFORMED_PATH'; | ||
return err; | ||
})(); | ||
} | ||
@@ -56,3 +71,7 @@ | ||
if (_.isUndefined(currentExemplar[0])) { | ||
throw new Error('Invalid keypath: "'+path+'" (unreachable in schema)'); | ||
throw (function (){ | ||
var err = new Error('Keypath: "'+path+'" is unreachable in schema'); | ||
err.code = 'E_UNREACHABLE'; | ||
return err; | ||
})(); | ||
} | ||
@@ -74,3 +93,7 @@ else { | ||
if (_.isUndefined(currentExemplar[hop])) { | ||
throw new Error('Invalid keypath: "'+path+'" (unreachable in schema)'); | ||
throw (function (){ | ||
var err = new Error('Keypath: "'+path+'" is unreachable in schema'); | ||
err.code = 'E_UNREACHABLE'; | ||
return err; | ||
})(); | ||
} | ||
@@ -96,3 +119,7 @@ else { | ||
else if (TYPES.lamda.isExemplar(currentExemplar)) { | ||
throw new Error('Invalid keypath: "'+path+'" (unreachable in schema)'); | ||
throw (function (){ | ||
var err = new Error('Keypath: "'+path+'" is unreachable in schema'); | ||
err.code = 'E_UNREACHABLE'; | ||
return err; | ||
})(); | ||
} | ||
@@ -102,3 +129,7 @@ | ||
else { | ||
throw new Error('Invalid keypath: "'+path+'" (unreachable in schema)'); | ||
throw (function (){ | ||
var err = new Error('Keypath: "'+path+'" is unreachable in schema'); | ||
err.code = 'E_UNREACHABLE'; | ||
return err; | ||
})(); | ||
} | ||
@@ -105,0 +136,0 @@ }); |
{ | ||
"name": "rttc", | ||
"version": "9.2.1", | ||
"version": "9.2.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
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
217590
4639