@hestia-earth/schema-validation 33.5.1 → 33.5.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": "33.5.1",
3
+ "version": "33.5.3",
4
4
  "description": "HESTIA Schema Validation",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
@@ -2,20 +2,24 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.init = exports.validate = exports.keyword = exports.isValidDate = exports.isFutureDate = void 0;
4
4
  var formatDate = function (date) { return new Date("".concat(new Date(date).toJSON().substring(0, 10), "T12:00:00.000Z")); };
5
+ var validLength = function (value, length) { return !value || value.length === length; };
5
6
  /**
6
7
  * JavaScript does a lenient parsing of dates, so even `2000-30-30` will return a date.
7
- * This makes sure the parse date is the date as the given date. *
8
+ * This makes sure the parse date is the date as the given date.
8
9
  *
9
10
  * @param value
10
11
  * @returns
11
12
  */
12
13
  var isValidDateRange = function (value) {
13
- var values = value.substring(0, 10).split('-').map(Number);
14
- var year = values[0] || 1970;
15
- var month = values[1] || 1;
16
- var day = values[2] || 1;
14
+ var values = value.substring(0, 10).split('-');
15
+ var year = Number(values[0]) || 1970;
16
+ var month = Number(values[1]) || 1;
17
+ var day = Number(values[2]) || 1;
17
18
  var date = new Date(year, month - 1, day, 12); // Months are 0-indexed
18
19
  return [
20
+ validLength(values[0], 4),
21
+ validLength(values[1], 2),
22
+ validLength(values[2], 2),
19
23
  date.getFullYear() === year,
20
24
  date.getMonth() === month - 1,
21
25
  date.getDate() === day