Comparing version 9.2.0 to 9.2.1
@@ -131,2 +131,8 @@ /** | ||
} | ||
// Reject RttcRefPlaceholders | ||
// (this is a special case so there is a placeholder value that ONLY validates stricly against the "ref" type) | ||
// (note that like anything else, RttcRefPlaceholders nested inside of a JSON/generic dict/generic array get sanitized into JSON-compatible things) | ||
if (val.constructor.name === 'RttcRefPlaceholder') { | ||
return null; | ||
} | ||
return _.reduce(val,function (memo, subVal, key) { | ||
@@ -133,0 +139,0 @@ if (!_.isUndefined(subVal) && (allowNull || !_.isNull(subVal))) { |
@@ -68,2 +68,8 @@ /** | ||
// Reject RttcRefPlaceholders | ||
// (this is a special case so there is a placeholder value that ONLY validates against the "ref" type) | ||
if (_.isObject(v) && v.constructor.name === 'RttcRefPlaceholder') { | ||
throw new Error('E_runtimeInputTypeCoercionError'); | ||
} | ||
if(v === Infinity) { | ||
@@ -263,2 +269,7 @@ throw new Error('E_runtimeInputTypeCoercionError'); | ||
} | ||
// Reject RttcRefPlaceholders | ||
// (this is a special case so there is a placeholder value that ONLY validates against the "ref" type) | ||
if (_.isObject(v) && v.constructor.name === 'RttcRefPlaceholder') { | ||
return false; | ||
} | ||
return true; | ||
@@ -293,2 +304,8 @@ }, | ||
// Reject RttcRefPlaceholders | ||
// (this is a special case so there is a placeholder value that ONLY validates against the "ref" type) | ||
if (_.isObject(v) && v.constructor.name === 'RttcRefPlaceholder') { | ||
throw new Error('E_runtimeInputTypeCoercionError'); | ||
} | ||
// Also tolerate "pretty close" objects-- i.e. things which might have prototypal properties | ||
@@ -442,2 +459,7 @@ // and/or some weird getters and setters and stuff. | ||
} | ||
// Reject RttcRefPlaceholders | ||
// (this is a special case so there is a placeholder value that ONLY validates against the "ref" type) | ||
if (_.isObject(v) && v.constructor.name === 'RttcRefPlaceholder') { | ||
return false; | ||
} | ||
if (_.isString(v) || _.isNumber(v) || _.isBoolean(v) || _.isPlainObject(v) || _.isArray(v) || _.isNull(v)) { | ||
@@ -465,2 +487,7 @@ return true; | ||
} | ||
// Cannot coerce a RttcRefPlaceholder | ||
// (this is a special case so there is a placeholder value that ONLY validates against the "ref" type) | ||
if (_.isObject(v) && v.constructor.name === 'RttcRefPlaceholder') { | ||
throw new Error('E_runtimeInputTypeCoercionError'); | ||
} | ||
} | ||
@@ -552,3 +579,3 @@ | ||
// (Mi)spelling aliases | ||
TYPES.lambda = TYPES.lambda; | ||
TYPES.lambda = TYPES.lamda; | ||
@@ -555,0 +582,0 @@ // Case-folding aliases |
@@ -6,3 +6,2 @@ /** | ||
var util = require('util'); | ||
var Stream = require('stream').Stream; | ||
var _ = require('lodash'); | ||
@@ -9,0 +8,0 @@ var types = require('./types'); |
{ | ||
"name": "rttc", | ||
"version": "9.2.0", | ||
"version": "9.2.1", | ||
"description": "Runtime type-checking for JavaScript.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -559,8 +559,11 @@ # rttc | ||
##### .getBaseVal(sampleValue) | ||
##### .getBaseVal(exemplar) | ||
A convenience method to return the base value for the given exemplar. | ||
##### .cast(exemplar, actualValue) | ||
A convenience method that calls `rttc.infer()` on the provided exemplar to get the type schema, then uses it to `rttc.coerce()` the `actualValue` provided. | ||
## License | ||
@@ -567,0 +570,0 @@ |
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
216607
4608
573