freeman-check
Advanced tools
Comparing version 3.0.2 to 3.0.3
{ | ||
"name": "freeman-check", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"description": "Easy type and format checking on JavaScript objects", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.Check = void 0; | ||
const assert_1 = __importDefault(require("assert")); | ||
const CheckError_1 = require("./CheckError"); | ||
@@ -22,3 +21,4 @@ const jsonschema_1 = require("jsonschema"); | ||
constructor(schema) { | ||
(0, assert_1.default)(schema, new CheckError_1.CheckError(`Schema must be defined in constructor.`)); | ||
if (!schema) | ||
throw new CheckError_1.CheckError(`Schema must be defined in constructor.`); | ||
this.schema = schema; | ||
@@ -35,3 +35,4 @@ } | ||
} | ||
(0, assert_1.default)(this.schema, new CheckError_1.CheckError(`test can't be called on Check instances initialized without a schema.`)); | ||
if (!this.schema) | ||
throw new CheckError_1.CheckError(`test can't be called on Check instances initialized without a schema.`); | ||
// validate. | ||
@@ -72,3 +73,4 @@ const result = (0, jsonschema_1.validate)(object, this.schema); | ||
} | ||
(0, assert_1.default)(type, new CheckError_1.CheckError(`Validation failed, and then there was an internal error while determining the required type of ${subject}.`)); | ||
if (!type) | ||
throw new CheckError_1.CheckError(`Validation failed, and then there was an internal error while determining the required type of ${subject}.`); | ||
problem = 'needs to be ' + (0, anora_1.default)(type) + ' `' + type + '`'; | ||
@@ -75,0 +77,0 @@ break; |
296
16257