@bolttech/form-engine-core 0.0.1-beta.20 → 0.0.1-beta.22

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.
Files changed (2) hide show
  1. package/index.esm.js +15 -6
  2. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -2090,24 +2090,25 @@ const betweenDates = (value, validations) => {
2090
2090
  * ```
2091
2091
  */
2092
2092
  const date = (value, validations) => {
2093
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
2093
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
2094
2094
  if (!((_b = (_a = validations.date) === null || _a === void 0 ? void 0 : _a.target) === null || _b === void 0 ? void 0 : _b.value) && !((_d = (_c = validations.date) === null || _c === void 0 ? void 0 : _c.origin) === null || _d === void 0 ? void 0 : _d.intervals)) {
2095
2095
  return false;
2096
2096
  }
2097
2097
  const originValue = validations.date.origin.value || value;
2098
2098
  const mappedValue = dateRearrangeMapper[(_e = validations.date) === null || _e === void 0 ? void 0 : _e.origin.format](originValue).toString();
2099
- if (invalidStringDate(mappedValue, (_f = validations.date) === null || _f === void 0 ? void 0 : _f.origin.format)) return false;
2099
+ console.log('date: ', value, invalidStringDate(mappedValue, (_f = validations.date) === null || _f === void 0 ? void 0 : _f.origin.format));
2100
+ if (invalidStringDate(mappedValue, (_g = validations.date) === null || _g === void 0 ? void 0 : _g.origin.format)) return false;
2100
2101
  let originDate = new Date(mappedValue);
2101
2102
  let targetDate = new Date();
2102
2103
  let target = new Date();
2103
- if ((_h = (_g = validations.date) === null || _g === void 0 ? void 0 : _g.target) === null || _h === void 0 ? void 0 : _h.format) {
2104
- target = new Date(dateRearrangeMapper[(_k = (_j = validations.date) === null || _j === void 0 ? void 0 : _j.target) === null || _k === void 0 ? void 0 : _k.format](validations.date.target.value).toString());
2104
+ if ((_j = (_h = validations.date) === null || _h === void 0 ? void 0 : _h.target) === null || _j === void 0 ? void 0 : _j.format) {
2105
+ target = new Date(dateRearrangeMapper[(_l = (_k = validations.date) === null || _k === void 0 ? void 0 : _k.target) === null || _l === void 0 ? void 0 : _l.format](validations.date.target.value).toString());
2105
2106
  targetDate = target;
2106
2107
  }
2107
2108
  if (validations.date.origin.intervals) {
2108
2109
  targetDate = getIntervalsDate(originDate, validations.date.origin.intervals);
2109
2110
  const date = new Date();
2110
- if (((_l = validations.date.target) === null || _l === void 0 ? void 0 : _l.value) && target) {
2111
+ if (((_m = validations.date.target) === null || _m === void 0 ? void 0 : _m.value) && target) {
2111
2112
  date.setDate(target.getDate());
2112
2113
  date.setMonth(target.getMonth());
2113
2114
  }
@@ -2126,7 +2127,7 @@ const date = (value, validations) => {
2126
2127
  '===': originTimestamp === targetTimestamp,
2127
2128
  '!==': originTimestamp !== targetTimestamp
2128
2129
  };
2129
- return operationsMapper[(_m = validations.date) === null || _m === void 0 ? void 0 : _m.operator];
2130
+ return operationsMapper[(_o = validations.date) === null || _o === void 0 ? void 0 : _o.operator];
2130
2131
  };
2131
2132
  /**
2132
2133
  * @function validDate
@@ -2155,6 +2156,14 @@ const validDate = (value, validations) => {
2155
2156
  const month = parseInt(dateParts[0], 10) - 1; // Month is zero-based
2156
2157
  const day = parseInt(dateParts[1], 10);
2157
2158
  const date = new Date(year, month, day);
2159
+ /* This line is here because we need to guarantee that the field will not be valid while typing,
2160
+ * that is, imagine the scenario where the user wants to type 1995, when typing 19 or 199,
2161
+ * the function returns valid, as there is a year 19 or 199.
2162
+ */
2163
+ console.log('ValidDate: ', value);
2164
+ if (date.getFullYear() < 1900) {
2165
+ return true;
2166
+ }
2158
2167
  // Check if the date is valid
2159
2168
  const isValidDate = date.getFullYear() === year && date.getMonth() === month && date.getDate() === day;
2160
2169
  return !isValidDate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bolttech/form-engine-core",
3
- "version": "0.0.1-beta.20",
3
+ "version": "0.0.1-beta.22",
4
4
  "module": "./index.esm.js",
5
5
  "type": "module",
6
6
  "main": "./index.esm.js",