z-schema 4.2.1 → 5.0.0

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,8 +1,8 @@
1
1
  {
2
2
  "name": "z-schema",
3
- "version": "4.2.1",
3
+ "version": "5.0.0",
4
4
  "engines": {
5
- "node": ">=6.0.0"
5
+ "node": ">=8.0.0"
6
6
  },
7
7
  "description": "JSON schema validator",
8
8
  "homepage": "https://github.com/zaggino/z-schema",
@@ -68,7 +68,7 @@
68
68
  "dependencies": {
69
69
  "lodash.get": "^4.4.2",
70
70
  "lodash.isequal": "^4.5.0",
71
- "validator": "^11.0.0"
71
+ "validator": "^12.0.0"
72
72
  },
73
73
  "optionalDependencies": {
74
74
  "commander": "^2.7.1"
@@ -21,7 +21,9 @@ var JsonValidators = {
21
21
  return;
22
22
  }
23
23
 
24
- if (Utils.whatIs(json / schema.multipleOf) !== "integer") {
24
+ var stringMultipleOf = String(schema.multipleOf);
25
+ var scale = Math.pow(10, stringMultipleOf.length - stringMultipleOf.indexOf(".") - 1);
26
+ if (Utils.whatIs((json * scale) / (schema.multipleOf * scale)) !== "integer") {
25
27
  report.addError("MULTIPLE_OF", [json, schema.multipleOf], null, schema);
26
28
  }
27
29
  },
package/src/Report.js CHANGED
@@ -81,7 +81,7 @@ Report.prototype.processAsyncTasks = function (timeout, callback) {
81
81
  function finish() {
82
82
  process.nextTick(function () {
83
83
  var valid = self.errors.length === 0,
84
- err = valid ? undefined : self.errors;
84
+ err = valid ? null : self.errors;
85
85
  callback(err, valid);
86
86
  });
87
87
  }
package/src/ZSchema.js CHANGED
@@ -52,9 +52,9 @@ var defaultOptions = {
52
52
  strictMode: false,
53
53
  // report error paths as an array of path segments to get to the offending node
54
54
  reportPathAsArray: false,
55
- // stops validation as soon as an error is found, true by default but can be turned off
56
- breakOnFirstError: true,
57
- // check if schema follow best practices and common sence
55
+ // stop validation as soon as an error is found
56
+ breakOnFirstError: false,
57
+ // check if schema follows best practices and common sense
58
58
  pedanticCheck: false,
59
59
  // ignore unknown formats (do not report them as an error)
60
60
  ignoreUnknownFormats: false,
@@ -264,7 +264,7 @@ ZSchema.prototype.getLastError = function () {
264
264
  return e;
265
265
  };
266
266
  ZSchema.prototype.getLastErrors = function () {
267
- return this.lastReport && this.lastReport.errors.length > 0 ? this.lastReport.errors : undefined;
267
+ return this.lastReport && this.lastReport.errors.length > 0 ? this.lastReport.errors : null;
268
268
  };
269
269
  ZSchema.prototype.getMissingReferences = function (arr) {
270
270
  arr = arr || this.lastReport.errors;