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.
@@ -106,16 +106,30 @@ class Validator {
106
106
  }
107
107
  let property = entry.properties[0];
108
108
  let value = object[property];
109
- if (value == undefined) {
109
+ if (typeof value != 'object' || value === null) {
110
110
  continue;
111
111
  }
112
- let subMisfits = yield entry.validator.validate(value, options);
113
- if (subMisfits.length > 0) {
114
- for (let misfit of subMisfits) {
115
- misfit.addPrefix(property + '.');
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knight-validation",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "A validation lib",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",