z-schema 3.24.1 → 3.25.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "z-schema",
3
- "version": "3.24.1",
3
+ "version": "3.25.1",
4
4
  "description": "JSON schema validator",
5
5
  "homepage": "https://github.com/zaggino/z-schema",
6
6
  "authors": [
@@ -33,8 +33,11 @@
33
33
  ],
34
34
  "types": "index.d.ts",
35
35
  "scripts": {
36
- "prepublish": "npm test && grunt",
37
- "test": "jasmine-node test/ && grunt lint"
36
+ "prepare": "grunt",
37
+ "prepublishOnly": "npm test",
38
+ "test": "jasmine-node test/ && grunt lint",
39
+ "test-z": "jasmine-node test/spec/ZSchemaTestSuiteSpec.js",
40
+ "grunt": "grunt"
38
41
  },
39
42
  "testling": {
40
43
  "scripts": [
@@ -207,8 +207,11 @@ var JsonValidators = {
207
207
  }
208
208
  }
209
209
  }
210
- if (s.length > 0) {
211
- report.addError("OBJECT_ADDITIONAL_PROPERTIES", [s], null, schema);
210
+ var idx4 = s.length;
211
+ if (idx4) {
212
+ while (idx4--) {
213
+ report.addError("OBJECT_ADDITIONAL_PROPERTIES", [s[idx4]], null, schema);
214
+ }
212
215
  }
213
216
  }
214
217
  }
@@ -337,10 +340,14 @@ var JsonValidators = {
337
340
  var formatValidatorFn = FormatValidators[schema.format];
338
341
  if (typeof formatValidatorFn === "function") {
339
342
  if (formatValidatorFn.length === 2) {
340
- // async
343
+ // async - need to clone the path here, because it will change by the time async function reports back
344
+ var pathBeforeAsync = Utils.clone(report.path);
341
345
  report.addAsyncTask(formatValidatorFn, [json], function (result) {
342
346
  if (result !== true) {
347
+ var backup = report.path;
348
+ report.path = pathBeforeAsync;
343
349
  report.addError("INVALID_FORMAT", [schema.format, json], null, schema);
350
+ report.path = backup;
344
351
  }
345
352
  });
346
353
  } else {
@@ -455,6 +462,8 @@ var recurseObject = function (report, schema, json) {
455
462
  }
456
463
  };
457
464
 
465
+ exports.JsonValidators = JsonValidators;
466
+
458
467
  /**
459
468
  *
460
469
  * @param {Report} report