check-types-mini
Advanced tools
Comparing version 6.0.12 to 6.0.13
/** | ||
* check-types-mini | ||
* Validate options object | ||
* Version: 6.0.12 | ||
* Version: 6.0.13 | ||
* Author: Roy Revelt, Codsen Ltd | ||
@@ -14,2 +14,3 @@ * License: MIT | ||
var _typeof = require('@babel/runtime/helpers/typeof'); | ||
var _objectSpread = require('@babel/runtime/helpers/objectSpread2'); | ||
@@ -26,2 +27,3 @@ var typ = require('type-detect'); | ||
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof); | ||
var _objectSpread__default = /*#__PURE__*/_interopDefaultLegacy(_objectSpread); | ||
@@ -78,3 +80,3 @@ var typ__default = /*#__PURE__*/_interopDefaultLegacy(typ); | ||
} | ||
opts.msg = ("" + opts.msg).trim(); | ||
opts.msg = "".concat(opts.msg).trim(); | ||
if (opts.msg[opts.msg.length - 1] === ":") { | ||
@@ -90,3 +92,3 @@ opts.msg = opts.msg.slice(0, opts.msg.length - 1).trim(); | ||
if (!Array.isArray(current) && !isObj(current)) { | ||
tempObj[oneKey + "." + innerObj.path] = current; | ||
tempObj["".concat(oneKey, ".").concat(innerObj.path)] = current; | ||
} | ||
@@ -104,7 +106,7 @@ return current; | ||
opts.schema[oneKey] = opts.schema[oneKey].map(function (el) { | ||
return ("" + el).toLowerCase().trim(); | ||
return "".concat(el).toLowerCase().trim(); | ||
}); | ||
}); | ||
} else if (opts.schema != null) { | ||
throw new Error("check-types-mini: opts.schema was customised to " + JSON.stringify(opts.schema, null, 0) + " which is not object but " + typeof opts.schema); | ||
throw new Error("check-types-mini: opts.schema was customised to ".concat(JSON.stringify(opts.schema, null, 0), " which is not object but ").concat(_typeof__default['default'](opts.schema))); | ||
} | ||
@@ -118,3 +120,3 @@ if (!existy(ref)) { | ||
var keys = pullAll__default['default'](Object.keys(obj), Object.keys(ref).concat(Object.keys(opts.schema))); | ||
throw new TypeError(opts.msg + ": " + opts.optsVarName + ".enforceStrictKeyset is on and the following key" + (keys.length > 1 ? "s" : "") + " " + (keys.length > 1 ? "are" : "is") + " not covered by schema and/or reference objects: " + keys.join(", ")); | ||
throw new TypeError("".concat(opts.msg, ": ").concat(opts.optsVarName, ".enforceStrictKeyset is on and the following key").concat(keys.length > 1 ? "s" : "", " ").concat(keys.length > 1 ? "are" : "is", " not covered by schema and/or reference objects: ").concat(keys.join(", "))); | ||
} | ||
@@ -124,9 +126,9 @@ } else if (isObj(ref) && Object.keys(ref).length > 0) { | ||
var _keys = pullAll__default['default'](Object.keys(obj), Object.keys(ref)); | ||
throw new TypeError(opts.msg + ": The input object has key" + (_keys.length > 1 ? "s" : "") + " which " + (_keys.length > 1 ? "are" : "is") + " not covered by the reference object: " + _keys.join(", ")); | ||
throw new TypeError("".concat(opts.msg, ": The input object has key").concat(_keys.length > 1 ? "s" : "", " which ").concat(_keys.length > 1 ? "are" : "is", " not covered by the reference object: ").concat(_keys.join(", "))); | ||
} else if (pullAllWithGlob(pullAll__default['default'](Object.keys(ref), Object.keys(obj)), opts.ignoreKeys).length !== 0) { | ||
var _keys2 = pullAll__default['default'](Object.keys(ref), Object.keys(obj)); | ||
throw new TypeError(opts.msg + ": The reference object has key" + (_keys2.length > 1 ? "s" : "") + " which " + (_keys2.length > 1 ? "are" : "is") + " not present in the input object: " + _keys2.join(", ")); | ||
throw new TypeError("".concat(opts.msg, ": The reference object has key").concat(_keys2.length > 1 ? "s" : "", " which ").concat(_keys2.length > 1 ? "are" : "is", " not present in the input object: ").concat(_keys2.join(", "))); | ||
} | ||
} else { | ||
throw new TypeError(opts.msg + ": Both " + opts.optsVarName + ".schema and reference objects are missing! We don't have anything to match the keys as you requested via opts.enforceStrictKeyset!"); | ||
throw new TypeError("".concat(opts.msg, ": Both ").concat(opts.optsVarName, ".schema and reference objects are missing! We don't have anything to match the keys as you requested via opts.enforceStrictKeyset!")); | ||
} | ||
@@ -167,6 +169,6 @@ } | ||
if (opts.enforceStrictKeyset && isNotAnArrayChild && !optsSchemaHasThisPathDefined && !refHasThisPathDefined) { | ||
throw new TypeError(opts.msg + ": " + opts.optsVarName + "." + innerObj.path + " is neither covered by reference object (second input argument), nor " + opts.optsVarName + ".schema! To stop this error, turn off " + opts.optsVarName + ".enforceStrictKeyset or provide some type reference (2nd argument or " + opts.optsVarName + ".schema).\n\nDebug info:\n\nobj = " + JSON.stringify(obj, null, 4) + "\n\nref = " + JSON.stringify(ref, null, 4) + "\n\ninnerObj = " + JSON.stringify(innerObj, null, 4) + "\n\nopts = " + JSON.stringify(opts, null, 4) + "\n\ncurrent = " + JSON.stringify(current, null, 4) + "\n\n"); | ||
throw new TypeError("".concat(opts.msg, ": ").concat(opts.optsVarName, ".").concat(innerObj.path, " is neither covered by reference object (second input argument), nor ").concat(opts.optsVarName, ".schema! To stop this error, turn off ").concat(opts.optsVarName, ".enforceStrictKeyset or provide some type reference (2nd argument or ").concat(opts.optsVarName, ".schema).\n\nDebug info:\n\nobj = ").concat(JSON.stringify(obj, null, 4), "\n\nref = ").concat(JSON.stringify(ref, null, 4), "\n\ninnerObj = ").concat(JSON.stringify(innerObj, null, 4), "\n\nopts = ").concat(JSON.stringify(opts, null, 4), "\n\ncurrent = ").concat(JSON.stringify(current, null, 4), "\n\n")); | ||
} else if (optsSchemaHasThisPathDefined) { | ||
var currentKeysSchema = arrayiffyIfString.arrayiffy(opts.schema[innerObj.path]).map(function (el) { | ||
return ("" + el).toLowerCase(); | ||
return "".concat(el).toLowerCase(); | ||
}); | ||
@@ -179,7 +181,7 @@ objectPath__default['default'].set(opts.schema, innerObj.path, currentKeysSchema); | ||
if (!currentKeysSchema.includes(typ__default['default'](current[i]).toLowerCase())) { | ||
throw new TypeError(opts.msg + ": " + opts.optsVarName + "." + innerObj.path + "." + i + ", the " + i + "th element (equal to " + JSON.stringify(current[i], null, 0) + ") is of a type " + typ__default['default'](current[i]).toLowerCase() + ", but only the following are allowed by the " + opts.optsVarName + ".schema: " + currentKeysSchema.join(", ")); | ||
throw new TypeError("".concat(opts.msg, ": ").concat(opts.optsVarName, ".").concat(innerObj.path, ".").concat(i, ", the ").concat(i, "th element (equal to ").concat(JSON.stringify(current[i], null, 0), ") is of a type ").concat(typ__default['default'](current[i]).toLowerCase(), ", but only the following are allowed by the ").concat(opts.optsVarName, ".schema: ").concat(currentKeysSchema.join(", "))); | ||
} | ||
} | ||
} else { | ||
throw new TypeError(opts.msg + ": " + opts.optsVarName + "." + innerObj.path + " was customised to " + (typ__default['default'](current) !== "string" ? '"' : "") + JSON.stringify(current, null, 0) + (typ__default['default'](current) !== "string" ? '"' : "") + " (type: " + typ__default['default'](current).toLowerCase() + ") which is not among the allowed types in schema (which is equal to " + JSON.stringify(currentKeysSchema, null, 0) + ")"); | ||
throw new TypeError("".concat(opts.msg, ": ").concat(opts.optsVarName, ".").concat(innerObj.path, " was customised to ").concat(typ__default['default'](current) !== "string" ? '"' : "").concat(JSON.stringify(current, null, 0)).concat(typ__default['default'](current) !== "string" ? '"' : "", " (type: ").concat(typ__default['default'](current).toLowerCase(), ") which is not among the allowed types in schema (which is equal to ").concat(JSON.stringify(currentKeysSchema, null, 0), ")")); | ||
} | ||
@@ -197,6 +199,6 @@ } | ||
if (!allMatch) { | ||
throw new TypeError(opts.msg + ": " + opts.optsVarName + "." + innerObj.path + " was customised to be array, but not all of its elements are " + typ__default['default'](ref[key]).toLowerCase() + "-type"); | ||
throw new TypeError("".concat(opts.msg, ": ").concat(opts.optsVarName, ".").concat(innerObj.path, " was customised to be array, but not all of its elements are ").concat(typ__default['default'](ref[key]).toLowerCase(), "-type")); | ||
} | ||
} else if (typ__default['default'](current) !== typ__default['default'](compareTo)) { | ||
throw new TypeError(opts.msg + ": " + opts.optsVarName + "." + innerObj.path + " was customised to " + (typ__default['default'](current).toLowerCase() === "string" ? "" : '"') + JSON.stringify(current, null, 0) + (typ__default['default'](current).toLowerCase() === "string" ? "" : '"') + " which is not " + typ__default['default'](compareTo).toLowerCase() + " but " + typ__default['default'](current).toLowerCase()); | ||
throw new TypeError("".concat(opts.msg, ": ").concat(opts.optsVarName, ".").concat(innerObj.path, " was customised to ").concat(typ__default['default'](current).toLowerCase() === "string" ? "" : '"').concat(JSON.stringify(current, null, 0)).concat(typ__default['default'](current).toLowerCase() === "string" ? "" : '"', " which is not ").concat(typ__default['default'](compareTo).toLowerCase(), " but ").concat(typ__default['default'](current).toLowerCase())); | ||
} | ||
@@ -203,0 +205,0 @@ } else ; |
/** | ||
* check-types-mini | ||
* Validate options object | ||
* Version: 6.0.12 | ||
* Version: 6.0.13 | ||
* Author: Roy Revelt, Codsen Ltd | ||
@@ -6,0 +6,0 @@ * License: MIT |
/** | ||
* check-types-mini | ||
* Validate options object | ||
* Version: 6.0.12 | ||
* Version: 6.0.13 | ||
* Author: Roy Revelt, Codsen Ltd | ||
@@ -6,0 +6,0 @@ * License: MIT |
{ | ||
"name": "check-types-mini", | ||
"version": "6.0.12", | ||
"version": "6.0.13", | ||
"description": "Validate options object", | ||
@@ -37,5 +37,7 @@ "keywords": [ | ||
"build": "rollup -c", | ||
"esbuild": "node '../../scripts/esbuild.js'", | ||
"esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'", | ||
"ci_test": "npm run build && npm run format && tap --no-only --reporter=silent --output-file=testStats.md && npm run clean_cov", | ||
"dev": "rollup -c --dev", | ||
"devunittest": "npm run dev && ./node_modules/.bin/tap --only -R 'base' && npm run tsd && npm run clean_cov", | ||
"devunittest": "npm run dev && tap --only -R 'base'", | ||
"format": "npm run lect && npm run prettier && npm run lint", | ||
@@ -49,7 +51,6 @@ "lect": "lect", | ||
"tsc": "tsc", | ||
"tsd": "test ! -f index.d.ts || tsd", | ||
"pretest": "npm run build", | ||
"test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format", | ||
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier", | ||
"unittest": "./node_modules/.bin/tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run tsd && npm run clean_cov && npm run perf", | ||
"unittest": "./node_modules/.bin/tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf", | ||
"clean_cov": "../../scripts/leaveCoverageTotalOnly.js", | ||
@@ -85,4 +86,4 @@ "clean_types": "../../scripts/cleanTypes.js" | ||
"@babel/runtime": "^7.13.10", | ||
"arrayiffy-if-string": "^3.13.12", | ||
"ast-monkey-traverse": "^2.0.12", | ||
"arrayiffy-if-string": "^3.13.13", | ||
"ast-monkey-traverse": "^2.0.13", | ||
"lodash.intersection": "^4.4.0", | ||
@@ -119,4 +120,6 @@ "lodash.pullall": "^4.2.0", | ||
"@typescript-eslint/parser": "^4.20.0", | ||
"core-js": "^3.10.0", | ||
"cross-env": "^7.0.3", | ||
"eslint": "^7.23.0", | ||
"lect": "^0.16.12", | ||
"lect": "^0.16.13", | ||
"rollup": "^2.44.0", | ||
@@ -129,3 +132,2 @@ "rollup-plugin-ascii": "^0.0.3", | ||
"tap": "^14.11.0", | ||
"tsd": "^0.14.0", | ||
"tslib": "^2.1.0", | ||
@@ -132,0 +134,0 @@ "typescript": "^4.2.3" |
Sorry, the diff of this file is too big to display
195366
37
11
4569
Updatedarrayiffy-if-string@^3.13.13
Updatedast-monkey-traverse@^2.0.13