knight-validation 3.3.2 → 3.3.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.
@@ -93,6 +93,9 @@ class Validator {
93
93
  break;
94
94
  }
95
95
  }
96
+ if (entry.properties.length == 0 && misfittingProperties.indexOf(null) > -1) {
97
+ propertyAlreadyHasAMisfit = true;
98
+ }
96
99
  if (propertyAlreadyHasAMisfit) {
97
100
  l.dev('Property already has misfit. Skipping...');
98
101
  continue;
@@ -126,7 +129,7 @@ class Validator {
126
129
  l.called('entry.constraint.validate');
127
130
  }
128
131
  else if (entry.properties.length == 1) {
129
- l.dev('Constraint is to be applied to one property. Fetching its value...');
132
+ l.dev('Constraint is to be applied to one property');
130
133
  let property = entry.properties[0];
131
134
  let dotNotation = new DotNotation_1.DotNotation(property);
132
135
  let value = dotNotation.get(object);
@@ -148,6 +151,9 @@ class Validator {
148
151
  }
149
152
  misfit.properties = entry.properties.slice();
150
153
  misfittingProperties.push(...entry.properties);
154
+ if (entry.properties.length == 0) {
155
+ misfittingProperties.push(null);
156
+ }
151
157
  misfits.push(misfit);
152
158
  }
153
159
  }
@@ -178,7 +184,12 @@ class Validator {
178
184
  l.dev('Validator returned misfits', subMisfits);
179
185
  l.creator('Adding prefix to misfit properties...', `${property}[${i}].`);
180
186
  for (let misfit of subMisfits) {
181
- misfit.addPrefix(`${property}[${i}].`);
187
+ if (misfit.properties.length == 0) {
188
+ misfit.properties.push(`${property}[${i}]`);
189
+ }
190
+ else {
191
+ misfit.addPrefix(`${property}[${i}].`);
192
+ }
182
193
  }
183
194
  misfittingProperties.push(...entry.properties);
184
195
  misfits.push(...subMisfits);
@@ -194,7 +205,12 @@ class Validator {
194
205
  l.dev('Validator returned misfits', subMisfits);
195
206
  l.creator('Adding prefix to misfit properties...', property + '.');
196
207
  for (let misfit of subMisfits) {
197
- misfit.addPrefix(property + '.');
208
+ if (misfit.properties.length == 0) {
209
+ misfit.properties.push(property);
210
+ }
211
+ else {
212
+ misfit.addPrefix(property + '.');
213
+ }
198
214
  }
199
215
  misfittingProperties.push(...entry.properties);
200
216
  misfits.push(...subMisfits);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knight-validation",
3
- "version": "3.3.2",
3
+ "version": "3.3.3",
4
4
  "description": "A validation lib",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",