z-schema 4.1.1 → 4.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "z-schema",
3
- "version": "4.1.1",
3
+ "version": "4.2.3",
4
4
  "engines": {
5
5
  "node": ">=6.0.0"
6
6
  },
@@ -66,10 +66,9 @@
66
66
  ]
67
67
  },
68
68
  "dependencies": {
69
- "core-js": "^3.2.1",
70
69
  "lodash.get": "^4.4.2",
71
70
  "lodash.isequal": "^4.5.0",
72
- "validator": "^11.0.0"
71
+ "validator": "^12.0.0"
73
72
  },
74
73
  "optionalDependencies": {
75
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
  },
@@ -605,7 +607,7 @@ exports.validate = function (report, schema, json) {
605
607
  }
606
608
 
607
609
  if (typeof this.options.customValidator === "function") {
608
- this.options.customValidator(report, schema, json);
610
+ this.options.customValidator.call(this, report, schema, json);
609
611
  }
610
612
 
611
613
  // we don't need the root pointer anymore
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/Utils.js CHANGED
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/es/symbol");
4
-
5
3
  exports.jsonSymbol = Symbol.for("z-schema/json");
6
4
 
7
5
  exports.schemaSymbol = Symbol.for("z-schema/schema");
package/src/ZSchema.js CHANGED
@@ -54,7 +54,7 @@ var defaultOptions = {
54
54
  reportPathAsArray: false,
55
55
  // stops validation as soon as an error is found, true by default but can be turned off
56
56
  breakOnFirstError: true,
57
- // check if schema follow best practices and common sence
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;