knight-validation 2.0.2 → 2.0.3
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 +21 -7
- package/package.json +1 -1
package/lib/lib/Validator.js
CHANGED
|
@@ -106,16 +106,30 @@ class Validator {
|
|
|
106
106
|
}
|
|
107
107
|
let property = entry.properties[0];
|
|
108
108
|
let value = object[property];
|
|
109
|
-
if (value
|
|
109
|
+
if (typeof value != 'object' || value === null) {
|
|
110
110
|
continue;
|
|
111
111
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
if (value instanceof Array) {
|
|
113
|
+
for (let i = 0; i < value.length; i++) {
|
|
114
|
+
let subMisfits = yield entry.validator.validate(value[i], options);
|
|
115
|
+
if (subMisfits.length > 0) {
|
|
116
|
+
for (let misfit of subMisfits) {
|
|
117
|
+
misfit.addPrefix(`${property}[${i}].`);
|
|
118
|
+
}
|
|
119
|
+
misfittingProperties.push(...entry.properties);
|
|
120
|
+
misfits.push(...subMisfits);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
let subMisfits = yield entry.validator.validate(value, options);
|
|
126
|
+
if (subMisfits.length > 0) {
|
|
127
|
+
for (let misfit of subMisfits) {
|
|
128
|
+
misfit.addPrefix(property + '.');
|
|
129
|
+
}
|
|
130
|
+
misfittingProperties.push(...entry.properties);
|
|
131
|
+
misfits.push(...subMisfits);
|
|
116
132
|
}
|
|
117
|
-
misfittingProperties.push(...entry.properties);
|
|
118
|
-
misfits.push(...subMisfits);
|
|
119
133
|
}
|
|
120
134
|
}
|
|
121
135
|
}
|