@beabee/beabee-common 1.7.1 → 1.7.2

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.
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- // *** Definitions for rules ***
3
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
3
  if (k2 === undefined) k2 = k;
5
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -14,8 +13,14 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
14
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
15
  };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
17
19
  Object.defineProperty(exports, "__esModule", { value: true });
18
20
  exports.convertFiltersToRuleGroup = exports.convertRuleGroupToFilters = exports.validateRuleGroup = exports.validateRule = exports.isRuleGroup = exports.operatorsByType = exports.nullableOperators = exports.ruleOperators = void 0;
21
+ const isValid_1 = __importDefault(require("date-fns/isValid"));
22
+ const parseISO_1 = __importDefault(require("date-fns/parseISO"));
23
+ // *** Definitions for rules ***
19
24
  exports.ruleOperators = [
20
25
  "equal",
21
26
  "not_equal",
@@ -108,7 +113,7 @@ function validateRule(filters, rule) {
108
113
  return false; // Invalid value type
109
114
  }
110
115
  if (filter.type === "date" &&
111
- rule.value.some((v) => isNaN(+new Date(v)))) {
116
+ rule.value.some((v) => (0, isValid_1.default)((0, parseISO_1.default)(v)))) {
112
117
  return false; // Invalid date
113
118
  }
114
119
  return {
@@ -1,3 +1,5 @@
1
+ import isValid from "date-fns/isValid";
2
+ import parseISO from "date-fns/parseISO";
1
3
  // *** Definitions for rules ***
2
4
  export const ruleOperators = [
3
5
  "equal",
@@ -90,7 +92,7 @@ export function validateRule(filters, rule) {
90
92
  return false; // Invalid value type
91
93
  }
92
94
  if (filter.type === "date" &&
93
- rule.value.some((v) => isNaN(+new Date(v)))) {
95
+ rule.value.some((v) => isValid(parseISO(v)))) {
94
96
  return false; // Invalid date
95
97
  }
96
98
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beabee/beabee-common",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "description": "",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -28,5 +28,8 @@
28
28
  "prettier": "^2.7.1",
29
29
  "rimraf": "^3.0.2",
30
30
  "typescript": "^4.8.4"
31
+ },
32
+ "dependencies": {
33
+ "date-fns": "^2.29.3"
31
34
  }
32
35
  }