@hestia-earth/schema-validation 30.7.1 → 30.7.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": "@hestia-earth/schema-validation",
3
- "version": "30.7.1",
3
+ "version": "30.7.3",
4
4
  "description": "HESTIA Schema Validation",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
@@ -19,7 +19,8 @@ var validate = function (schema, data, _parentSchema, dataPath, parentData) {
19
19
  : null;
20
20
  })
21
21
  .filter(Boolean);
22
- exports.validate.errors = errors;
22
+ // only return the first 100 errors to limit the memory footprint
23
+ exports.validate.errors = errors.slice(0, 100);
23
24
  return errors.length === 0;
24
25
  };
25
26
  exports.validate = validate;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.init = exports.validate = exports.keyword = exports.isValidDate = void 0;
4
+ var formatDate = function (date) { return new Date("".concat(new Date(date).toJSON().substring(0, 10), "T12:00:00.000Z")); };
4
5
  /**
5
6
  * JavaScript does a lenient parsing of dates, so even `2000-30-30` will return a date.
6
7
  * This makes sure the parse date is the date as the given date. *
@@ -14,7 +15,7 @@ var isValidDateRange = function (value) {
14
15
  var month = values[1] || 1;
15
16
  var day = values[2] || 1;
16
17
  var date = new Date(year, month - 1, day, 12); // Months are 0-indexed
17
- return (date <= new Date() && // date cannot be in the future
18
+ return (formatDate(date) <= formatDate(new Date()) && // date cannot be in the future
18
19
  date.getFullYear() === year &&
19
20
  date.getMonth() === month - 1 && // Months are 0-indexed
20
21
  date.getDate() === day);
@@ -40,7 +41,8 @@ var validate = function (_schema, value, _parentSchema, dataPath) {
40
41
  };
41
42
  })
42
43
  .filter(Boolean);
43
- exports.validate.errors = errors;
44
+ // only return the first 100 errors to limit the memory footprint
45
+ exports.validate.errors = errors.slice(0, 100);
44
46
  return errors.length === 0;
45
47
  };
46
48
  exports.validate = validate;
@@ -18,7 +18,8 @@ var validate = function (_schema, value, _parentSchema, dataPath) {
18
18
  };
19
19
  })
20
20
  .filter(Boolean);
21
- exports.validate.errors = errors;
21
+ // only return the first 100 errors to limit the memory footprint
22
+ exports.validate.errors = errors.slice(0, 100);
22
23
  return errors.length === 0;
23
24
  };
24
25
  exports.validate = validate;