knight-validation 3.3.0 → 3.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/lib/Validator.js +10 -2
- package/package.json +1 -1
package/lib/lib/Validator.js
CHANGED
|
@@ -14,7 +14,7 @@ const knight_log_1 = require("knight-log");
|
|
|
14
14
|
const Constraint_1 = require("./Constraint");
|
|
15
15
|
const DotNotation_1 = require("./DotNotation");
|
|
16
16
|
const QuickConstraint_1 = require("./constraints/QuickConstraint");
|
|
17
|
-
let log = new knight_log_1.Log('knight-
|
|
17
|
+
let log = new knight_log_1.Log('knight-validation/Validator.ts');
|
|
18
18
|
class Validator {
|
|
19
19
|
constructor(options) {
|
|
20
20
|
this.entries = [];
|
|
@@ -85,7 +85,7 @@ class Validator {
|
|
|
85
85
|
let misfittingProperties = [];
|
|
86
86
|
for (let entry of this.entries) {
|
|
87
87
|
let constraintOrValidatorName = entry.constraint ? (_a = entry.constraint) === null || _a === void 0 ? void 0 : _a.name : entry.validator ? entry.validator.constructor.name : '';
|
|
88
|
-
l.location = ['' + entry.properties + ' ' + constraintOrValidatorName];
|
|
88
|
+
l.location = ['' + JSON.stringify(entry.properties) + ' > ' + constraintOrValidatorName];
|
|
89
89
|
let propertyAlreadyHasAMisfit = false;
|
|
90
90
|
for (let property of entry.properties) {
|
|
91
91
|
if (misfittingProperties.indexOf(property) > -1) {
|
|
@@ -160,9 +160,17 @@ class Validator {
|
|
|
160
160
|
let property = entry.properties[0];
|
|
161
161
|
let dotNotation = new DotNotation_1.DotNotation(property);
|
|
162
162
|
let value = dotNotation.get(object);
|
|
163
|
+
if (typeof value != 'object' || value === null) {
|
|
164
|
+
l.dev('Value of the property is not of type object or null. Skipping...', value);
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
163
167
|
if (value instanceof Array) {
|
|
164
168
|
l.dev('Value of the property is an array. Iterating its elements...');
|
|
165
169
|
for (let i = 0; i < value.length; i++) {
|
|
170
|
+
if (typeof value[i] != 'object' || value[i] === null) {
|
|
171
|
+
l.dev('Array element is not of type object or null. Skipping...', value[i]);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
166
174
|
l.calling('entry.validator.validate', value[i], options);
|
|
167
175
|
let subMisfits = yield entry.validator.validate(value[i], options);
|
|
168
176
|
l.called('entry.validator.validate');
|