@finnair/v-validation-luxon 1.1.0 → 3.0.0-alpha.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/CHANGELOG.md CHANGED
@@ -3,6 +3,39 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.0.0-alpha.0](https://github.com/finnair/v-validation/compare/v2.0.0...v3.0.0-alpha.0) (2022-09-26)
7
+
8
+
9
+ ### Features
10
+
11
+ * Use SyncPromise also in schema and luxon ([e8590b8](https://github.com/finnair/v-validation/commit/e8590b8c2a44ad28fde88f8682f53628ecf74a0f))
12
+
13
+
14
+
15
+
16
+
17
+ # [2.0.0](https://github.com/finnair/v-validation/compare/v1.1.0...v2.0.0) (2022-09-08)
18
+
19
+
20
+ * Upgrade All Dependencies (#80) ([fb6309c](https://github.com/finnair/v-validation/commit/fb6309cc1d9fd90f3e8c5ba79798fae1450b66a6)), closes [#80](https://github.com/finnair/v-validation/issues/80)
21
+
22
+
23
+ ### Features
24
+
25
+ * Implement toString in Luxon wrapper types ([#79](https://github.com/finnair/v-validation/issues/79)) ([3f3f3e8](https://github.com/finnair/v-validation/commit/3f3f3e8a4172c7803a7be4809f06aba554f7090f))
26
+
27
+
28
+ ### BREAKING CHANGES
29
+
30
+ * Drop Node 12 support
31
+ * Add .nvmrc
32
+ * Introduce CI build for Node 18
33
+ * Upgrade All Dependencies
34
+
35
+
36
+
37
+
38
+
6
39
  # [1.1.0](https://github.com/finnair/v-validation/compare/v1.0.1...v1.1.0) (2022-08-29)
7
40
 
8
41
 
package/dist/Vluxon.d.ts CHANGED
@@ -12,7 +12,7 @@ export interface ValidateLuxonParams {
12
12
  proto?: any;
13
13
  parser: (value: string, match: RegExpExecArray) => DateTime;
14
14
  }
15
- export declare function validateLuxon({ value, path, ctx, type, proto, pattern, parser }: ValidateLuxonParams): Promise<ValidationResult>;
15
+ export declare function validateLuxon({ value, path, ctx, type, proto, pattern, parser }: ValidateLuxonParams): PromiseLike<ValidationResult>;
16
16
  declare function localDate(options?: DateTimeOptions): import("@finnair/v-validation").ValidatorFnWrapper;
17
17
  declare function localTime(options?: DateTimeOptions): import("@finnair/v-validation").ValidatorFnWrapper;
18
18
  declare function dateTime(options?: DateTimeOptions): import("@finnair/v-validation").ValidatorFnWrapper;
package/dist/Vluxon.js CHANGED
@@ -14,32 +14,30 @@ const v_validation_1 = require("@finnair/v-validation");
14
14
  const luxon_1 = require("luxon");
15
15
  const luxon_2 = require("./luxon");
16
16
  function validateLuxon({ value, path, ctx, type, proto, pattern, parser }) {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- if ((0, v_validation_1.isNullOrUndefined)(value)) {
19
- return ctx.failure(v_validation_1.defaultViolations.notNull(path), value);
20
- }
21
- if (proto && value instanceof proto) {
22
- return ctx.success(value);
23
- }
24
- else if (luxon_1.DateTime.isDateTime(value)) {
25
- if (value.isValid) {
26
- return success(value);
27
- }
17
+ if ((0, v_validation_1.isNullOrUndefined)(value)) {
18
+ return ctx.failurePromise(v_validation_1.defaultViolations.notNull(path), value);
19
+ }
20
+ if (proto && value instanceof proto) {
21
+ return ctx.successPromise(value);
22
+ }
23
+ else if (luxon_1.DateTime.isDateTime(value)) {
24
+ if (value.isValid) {
25
+ return success(value);
28
26
  }
29
- else if ((0, v_validation_1.isString)(value)) {
30
- const match = pattern.exec(value);
31
- if (match) {
32
- const dateTime = parser(value, match);
33
- if (dateTime.isValid) {
34
- return success(dateTime);
35
- }
27
+ }
28
+ else if ((0, v_validation_1.isString)(value)) {
29
+ const match = pattern.exec(value);
30
+ if (match) {
31
+ const dateTime = parser(value, match);
32
+ if (dateTime.isValid) {
33
+ return success(dateTime);
36
34
  }
37
35
  }
38
- return ctx.failure(v_validation_1.defaultViolations.date(value, path, type), value);
39
- function success(dateTime) {
40
- return ctx.success(proto ? new proto(dateTime) : dateTime);
41
- }
42
- });
36
+ }
37
+ return ctx.failurePromise(v_validation_1.defaultViolations.date(value, path, type), value);
38
+ function success(dateTime) {
39
+ return ctx.successPromise(proto ? new proto(dateTime) : dateTime);
40
+ }
43
41
  }
44
42
  exports.validateLuxon = validateLuxon;
45
43
  const datePattern = /^\d{4}-\d{2}-\d{2}$/;
package/dist/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/dist/luxon.d.ts CHANGED
@@ -10,6 +10,7 @@ export declare abstract class LuxonDateTime {
10
10
  new (...args: any[]): T;
11
11
  }): T;
12
12
  equals(other: any): boolean;
13
+ toString(): string;
13
14
  abstract wrap(fn: (dateTime: DateTime) => DateTime): LuxonDateTime;
14
15
  abstract toJSON(): string;
15
16
  }
package/dist/luxon.js CHANGED
@@ -33,6 +33,9 @@ class LuxonDateTime {
33
33
  }
34
34
  return false;
35
35
  }
36
+ toString() {
37
+ return this.toJSON();
38
+ }
36
39
  }
37
40
  exports.LuxonDateTime = LuxonDateTime;
38
41
  class LocalDateLuxon extends LuxonDateTime {
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var _a, _b;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  const luxon_1 = require("luxon");
4
- console.log(luxon_1.DateTime.fromSQL('09:24:15').toJSON());
5
+ console.log(luxon_1.DateTime.fromMillis(luxon_1.DateTime.fromISO('2022-08-30T23:00:00Z').toMillis(), { zone: luxon_1.FixedOffsetZone.instance(180) }).toJSON());
6
+ let o = { foo: 1 };
7
+ console.log((_b = (_a = o.foo) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : 'not found');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finnair/v-validation-luxon",
3
- "version": "1.1.0",
3
+ "version": "3.0.0-alpha.0",
4
4
  "private": false,
5
5
  "description": "Luxon validators",
6
6
  "main": "dist/index.js",
@@ -25,12 +25,12 @@
25
25
  "build": "tsc -b ."
26
26
  },
27
27
  "dependencies": {
28
- "@finnair/path": "^1.1.0",
29
- "@finnair/v-validation": "^1.1.0",
30
- "luxon": "3.0.1"
28
+ "@finnair/path": "^2.0.0",
29
+ "@finnair/v-validation": "^3.0.0-alpha.0",
30
+ "luxon": "3.0.3"
31
31
  },
32
32
  "devDependencies": {
33
- "@types/luxon": "3.0.0"
33
+ "@types/luxon": "3.0.1"
34
34
  },
35
- "gitHead": "860263e814c178790766b48e22d8a8995e33ae40"
35
+ "gitHead": "f41f76dbe0365314dc15c07d3db2ad5a7b5e4109"
36
36
  }