@hestia-earth/schema-validation 30.3.2 → 30.4.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,6 +1,6 @@
1
1
  {
2
2
  "name": "@hestia-earth/schema-validation",
3
- "version": "30.3.2",
3
+ "version": "30.4.0",
4
4
  "description": "HESTIA Schema Validation",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
@@ -52,14 +52,21 @@ var findIdenticalIndexes = function (values) { return function (value, index) {
52
52
  return otherIndex;
53
53
  })
54
54
  }); }; };
55
+ /**
56
+ * Make sure empty JSON are not set as `'{}'`.
57
+ *
58
+ * @param value
59
+ * @returns
60
+ */
61
+ var toString = function (value) { return Object.values(value).filter(Boolean).length ? JSON.stringify(value) : null; };
55
62
  var validate = function (schema, data, _parentSchema, dataPath) {
56
63
  if (dataPath === void 0) { dataPath = ''; }
57
64
  var values = data.map(function (item) {
58
- return JSON.stringify(schema.reduce(function (prev, key) {
65
+ return toString(schema.reduce(function (prev, key) {
59
66
  var _a;
60
67
  return (__assign(__assign({}, prev), (_a = {}, _a[key] = getItemValue(item, key), _a)));
61
68
  }, {}));
62
- });
69
+ }).filter(Boolean);
63
70
  var indexes = values
64
71
  .map(findIdenticalIndexes(values))
65
72
  .filter(function (_a) {