@finnair/v-validation-luxon 3.0.0 → 3.1.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,179 +3,105 @@
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](https://github.com/finnair/v-validation/compare/v2.0.0...v3.0.0) (2022-10-03)
7
-
8
- **Note:** Version bump only for package @finnair/v-validation-luxon
9
-
10
-
11
-
12
-
13
-
14
- # [3.0.0-alpha.2](https://github.com/finnair/v-validation/compare/v2.0.0...v3.0.0-alpha.2) (2022-09-28)
15
-
16
-
17
- ### Features
18
-
19
- * Use SyncPromise also in schema and luxon ([792fbb4](https://github.com/finnair/v-validation/commit/792fbb4c78d07ea085d669312fef5e44e7a397fd))
20
-
21
-
22
-
23
-
24
-
25
- # [3.0.0-alpha.1](https://github.com/finnair/v-validation/compare/v2.0.0...v3.0.0-alpha.1) (2022-09-26)
6
+ # [3.1.0](https://github.com/finnair/v-validation/compare/v3.0.0...v3.1.0) (2022-10-24)
26
7
 
27
8
 
28
9
  ### Features
29
10
 
30
- * Use SyncPromise also in schema and luxon ([792fbb4](https://github.com/finnair/v-validation/commit/792fbb4c78d07ea085d669312fef5e44e7a397fd))
31
-
11
+ * LocalDateTimeLuxon (a date-time without timezone) ([#83](https://github.com/finnair/v-validation/issues/83)) ([1517c6e](https://github.com/finnair/v-validation/commit/1517c6ec8af835cb928cd6cf228b9bdc9f0cda3e))
32
12
 
33
13
 
34
14
 
35
15
 
36
- # [3.0.0-alpha.0](https://github.com/finnair/v-validation/compare/v2.0.0...v3.0.0-alpha.0) (2022-09-26)
37
16
 
17
+ # [3.0.0](https://github.com/finnair/v-validation/compare/v2.0.0...v3.0.0) (2022-10-03)
38
18
 
39
19
  ### Features
40
20
 
41
- * Use SyncPromise also in schema and luxon ([e8590b8](https://github.com/finnair/v-validation/commit/e8590b8c2a44ad28fde88f8682f53628ecf74a0f))
42
-
43
-
21
+ - Optimize performance.
22
+ - Use Object.freeze to ensure Validator immutability.
44
23
 
24
+ ### BREAKING CHANGES
45
25
 
26
+ - LuxonValidator class instead of validateLuxon function.
46
27
 
47
28
  # [2.0.0](https://github.com/finnair/v-validation/compare/v1.1.0...v2.0.0) (2022-09-08)
48
29
 
49
-
50
- * Upgrade All Dependencies (#80) ([fb6309c](https://github.com/finnair/v-validation/commit/fb6309cc1d9fd90f3e8c5ba79798fae1450b66a6)), closes [#80](https://github.com/finnair/v-validation/issues/80)
51
-
30
+ - Upgrade All Dependencies (#80) ([fb6309c](https://github.com/finnair/v-validation/commit/fb6309cc1d9fd90f3e8c5ba79798fae1450b66a6)), closes [#80](https://github.com/finnair/v-validation/issues/80)
52
31
 
53
32
  ### Features
54
33
 
55
- * Implement toString in Luxon wrapper types ([#79](https://github.com/finnair/v-validation/issues/79)) ([3f3f3e8](https://github.com/finnair/v-validation/commit/3f3f3e8a4172c7803a7be4809f06aba554f7090f))
56
-
34
+ - Implement toString in Luxon wrapper types ([#79](https://github.com/finnair/v-validation/issues/79)) ([3f3f3e8](https://github.com/finnair/v-validation/commit/3f3f3e8a4172c7803a7be4809f06aba554f7090f))
57
35
 
58
36
  ### BREAKING CHANGES
59
37
 
60
- * Drop Node 12 support
61
- * Add .nvmrc
62
- * Introduce CI build for Node 18
63
- * Upgrade All Dependencies
64
-
65
-
66
-
67
-
38
+ - Drop Node 12 support
39
+ - Add .nvmrc
40
+ - Introduce CI build for Node 18
41
+ - Upgrade All Dependencies
68
42
 
69
43
  # [1.1.0](https://github.com/finnair/v-validation/compare/v1.0.1...v1.1.0) (2022-08-29)
70
44
 
71
-
72
45
  ### Features
73
46
 
74
- * Support for Luxon ([94b3806](https://github.com/finnair/v-validation/commit/94b38060e07feeb0abb8c81659d8bda537a4d9aa))
75
-
76
-
77
-
78
-
47
+ - Support for Luxon ([94b3806](https://github.com/finnair/v-validation/commit/94b38060e07feeb0abb8c81659d8bda537a4d9aa))
79
48
 
80
49
  # [1.1.0-alpha.9](https://github.com/finnair/v-validation/compare/v1.1.0-alpha.8...v1.1.0-alpha.9) (2022-08-19)
81
50
 
82
51
  **Note:** Version bump only for package @finnair/v-validation-luxon
83
52
 
84
-
85
-
86
-
87
-
88
53
  # [1.1.0-alpha.8](https://github.com/finnair/v-validation/compare/v1.1.0-alpha.7...v1.1.0-alpha.8) (2022-08-19)
89
54
 
90
55
  **Note:** Version bump only for package @finnair/v-validation-luxon
91
56
 
92
-
93
-
94
-
95
-
96
57
  # [1.1.0-alpha.7](https://github.com/finnair/v-validation/compare/v1.1.0-alpha.6...v1.1.0-alpha.7) (2022-08-18)
97
58
 
98
59
  **Note:** Version bump only for package @finnair/v-validation-luxon
99
60
 
100
-
101
-
102
-
103
-
104
61
  # [1.1.0-alpha.6](https://github.com/finnair/v-validation/compare/v1.0.1...v1.1.0-alpha.6) (2022-08-17)
105
62
 
106
-
107
63
  ### Bug Fixes
108
64
 
109
- * Fix exports ([b9eacb6](https://github.com/finnair/v-validation/commit/b9eacb6e98a05a07049eb0a8f97b7e6b4958973a))
110
-
65
+ - Fix exports ([b9eacb6](https://github.com/finnair/v-validation/commit/b9eacb6e98a05a07049eb0a8f97b7e6b4958973a))
111
66
 
112
67
  ### Features
113
68
 
114
- * fromISO helper for Luxon wrapper construction ([e3b8f24](https://github.com/finnair/v-validation/commit/e3b8f247b3a9bfef8ad474688f995862fdd810e3))
115
- * Support for Luxon ([00d0a8e](https://github.com/finnair/v-validation/commit/00d0a8e8c8de46bfeb3502f51bb8cd5a3627070e))
116
-
117
-
118
-
119
-
69
+ - fromISO helper for Luxon wrapper construction ([e3b8f24](https://github.com/finnair/v-validation/commit/e3b8f247b3a9bfef8ad474688f995862fdd810e3))
70
+ - Support for Luxon ([00d0a8e](https://github.com/finnair/v-validation/commit/00d0a8e8c8de46bfeb3502f51bb8cd5a3627070e))
120
71
 
121
72
  # [1.1.0-alpha.5](https://github.com/finnair/v-validation/compare/v1.0.1...v1.1.0-alpha.5) (2022-08-16)
122
73
 
123
-
124
74
  ### Bug Fixes
125
75
 
126
- * Fix exports ([904e63c](https://github.com/finnair/v-validation/commit/904e63c4a40e65d274349ae0f5ea80c697c5c8ce))
127
-
76
+ - Fix exports ([904e63c](https://github.com/finnair/v-validation/commit/904e63c4a40e65d274349ae0f5ea80c697c5c8ce))
128
77
 
129
78
  ### Features
130
79
 
131
- * fromISO helper for Luxon wrapper construction ([81d5b2e](https://github.com/finnair/v-validation/commit/81d5b2eb08f360ab56ec0c6caece392a0e6eb1a1))
132
- * Support for Luxon ([6a243f0](https://github.com/finnair/v-validation/commit/6a243f043db2ca6700180eb758a08d8edfe1e538))
133
-
134
-
135
-
136
-
80
+ - fromISO helper for Luxon wrapper construction ([81d5b2e](https://github.com/finnair/v-validation/commit/81d5b2eb08f360ab56ec0c6caece392a0e6eb1a1))
81
+ - Support for Luxon ([6a243f0](https://github.com/finnair/v-validation/commit/6a243f043db2ca6700180eb758a08d8edfe1e538))
137
82
 
138
83
  # [1.1.0-alpha.4](https://github.com/finnair/v-validation/compare/v1.1.0-alpha.3...v1.1.0-alpha.4) (2022-08-15)
139
84
 
140
85
  **Note:** Version bump only for package @finnair/v-validation-luxon
141
86
 
142
-
143
-
144
-
145
-
146
87
  # [1.1.0-alpha.3](https://github.com/finnair/v-validation/compare/v1.1.0-alpha.2...v1.1.0-alpha.3) (2022-08-15)
147
88
 
148
89
  **Note:** Version bump only for package @finnair/v-validation-luxon
149
90
 
150
-
151
-
152
-
153
-
154
91
  # [1.1.0-alpha.2](https://github.com/finnair/v-validation/compare/v1.1.0-alpha.1...v1.1.0-alpha.2) (2022-08-12)
155
92
 
156
-
157
93
  ### Bug Fixes
158
94
 
159
- * Fix exports ([c4c42f7](https://github.com/finnair/v-validation/commit/c4c42f715e8c52b29b76f7f07753f632528a69ab))
160
-
161
-
162
-
163
-
95
+ - Fix exports ([c4c42f7](https://github.com/finnair/v-validation/commit/c4c42f715e8c52b29b76f7f07753f632528a69ab))
164
96
 
165
97
  # [1.1.0-alpha.1](https://github.com/finnair/v-validation/compare/v1.1.0-alpha.0...v1.1.0-alpha.1) (2022-08-12)
166
98
 
167
-
168
99
  ### Features
169
100
 
170
- * fromISO helper for Luxon wrapper construction ([187796e](https://github.com/finnair/v-validation/commit/187796e707f44033d94943ef64d48626317b4d80))
171
-
172
-
173
-
174
-
101
+ - fromISO helper for Luxon wrapper construction ([187796e](https://github.com/finnair/v-validation/commit/187796e707f44033d94943ef64d48626317b4d80))
175
102
 
176
103
  # [1.1.0-alpha.0](https://github.com/finnair/v-validation/compare/v1.0.1...v1.1.0-alpha.0) (2022-08-12)
177
104
 
178
-
179
105
  ### Features
180
106
 
181
- * Support for Luxon ([6f982df](https://github.com/finnair/v-validation/commit/6f982df9b55395e953069914c93fef677dec171e))
107
+ - Support for Luxon ([6f982df](https://github.com/finnair/v-validation/commit/6f982df9b55395e953069914c93fef677dec171e))
package/dist/Vluxon.d.ts CHANGED
@@ -16,6 +16,7 @@ export declare class LuxonValidator extends Validator {
16
16
  }
17
17
  declare function localDate(options?: DateTimeOptions): LuxonValidator;
18
18
  declare function localTime(options?: DateTimeOptions): LuxonValidator;
19
+ declare function localDateTime(options?: DateTimeOptions): LuxonValidator;
19
20
  declare function dateTime(options?: DateTimeOptions): LuxonValidator;
20
21
  declare function dateTimeUtc(options?: DateTimeOptions): LuxonValidator;
21
22
  declare function dateTimeMillis(options?: DateTimeOptions): LuxonValidator;
@@ -40,6 +41,7 @@ export declare class DurationValidator extends Validator {
40
41
  export declare const Vluxon: {
41
42
  localDate: typeof localDate;
42
43
  localTime: typeof localTime;
44
+ localDateTime: typeof localDateTime;
43
45
  dateTime: typeof dateTime;
44
46
  dateTimeUtc: typeof dateTimeUtc;
45
47
  dateTimeMillis: typeof dateTimeMillis;
package/dist/Vluxon.js CHANGED
@@ -67,12 +67,21 @@ function localTime(options = { zone: luxon_1.FixedOffsetZone.utcInstance }) {
67
67
  parser: (value) => luxon_1.DateTime.fromISO(value, options),
68
68
  });
69
69
  }
70
- const dateTimePattern = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:Z|[+-]\d{2}(?::?\d{2})?)$/;
70
+ const localDateTimePattern = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/;
71
+ function localDateTime(options = { zone: luxon_1.FixedOffsetZone.utcInstance }) {
72
+ return new LuxonValidator({
73
+ type: 'DateTime',
74
+ proto: luxon_2.LocalDateTimeLuxon,
75
+ pattern: localDateTimePattern,
76
+ parser: (value) => luxon_1.DateTime.fromISO(value, options),
77
+ });
78
+ }
79
+ const dateTimeTzPattern = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:Z|[+-]\d{2}(?::?\d{2})?)$/;
71
80
  function dateTime(options = { setZone: true }) {
72
81
  return new LuxonValidator({
73
82
  type: 'DateTime',
74
83
  proto: luxon_2.DateTimeLuxon,
75
- pattern: dateTimePattern,
84
+ pattern: dateTimeTzPattern,
76
85
  parser: (value) => luxon_1.DateTime.fromISO(value, options),
77
86
  });
78
87
  }
@@ -80,7 +89,7 @@ function dateTimeUtc(options = { zone: luxon_1.FixedOffsetZone.utcInstance }) {
80
89
  return new LuxonValidator({
81
90
  type: 'DateTime',
82
91
  proto: luxon_2.DateTimeUtcLuxon,
83
- pattern: dateTimePattern,
92
+ pattern: dateTimeTzPattern,
84
93
  parser: (value) => luxon_1.DateTime.fromISO(value, options),
85
94
  });
86
95
  }
@@ -192,6 +201,7 @@ exports.Vluxon = {
192
201
  // DateTime wrapper validators
193
202
  localDate,
194
203
  localTime,
204
+ localDateTime,
195
205
  dateTime,
196
206
  dateTimeUtc,
197
207
  dateTimeMillis,
package/dist/luxon.d.ts CHANGED
@@ -44,6 +44,21 @@ export declare class LocalTimeLuxon extends LuxonDateTime {
44
44
  wrap(fn: (dateTime: DateTime) => DateTime): LocalTimeLuxon;
45
45
  toJSON(): string;
46
46
  }
47
+ export declare class LocalDateTimeLuxon extends LuxonDateTime {
48
+ static readonly format = "yyyy-MM-dd'T'HH:mm:ss";
49
+ constructor(input: LuxonDateTimeInput);
50
+ static nowLocal(options?: DateTimeJSOptions): LocalDateTimeLuxon;
51
+ static nowUtc(): LocalDateTimeLuxon;
52
+ static fromISO(value: string, options?: DateTimeOptions): LocalDateTimeLuxon;
53
+ static fromFormat(value: string, format: string, options?: DateTimeOptions): LocalDateTimeLuxon;
54
+ static fromJSDate(date: Date, options?: {
55
+ zone?: string | Zone;
56
+ }): LocalDateTimeLuxon;
57
+ static fromMillis(millis: number, options?: DateTimeJSOptions): LocalDateTimeLuxon;
58
+ protected normalize(dateTime: DateTime): DateTime;
59
+ wrap(fn: (dateTime: DateTime) => DateTime): LocalDateTimeLuxon;
60
+ toJSON(): string;
61
+ }
47
62
  export declare class DateTimeLuxon extends LuxonDateTime {
48
63
  static readonly format = "yyyy-MM-dd'T'HH:mm:ss";
49
64
  static readonly formatTz: string;
package/dist/luxon.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a, _b;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.DateTimeMillisUtcLuxon = exports.DateTimeMillisLuxon = exports.DateTimeUtcLuxon = exports.DateTimeLuxon = exports.LocalTimeLuxon = exports.LocalDateLuxon = exports.LuxonDateTime = void 0;
4
+ exports.DateTimeMillisUtcLuxon = exports.DateTimeMillisLuxon = exports.DateTimeUtcLuxon = exports.DateTimeLuxon = exports.LocalDateTimeLuxon = exports.LocalTimeLuxon = exports.LocalDateLuxon = exports.LuxonDateTime = void 0;
5
5
  const luxon_1 = require("luxon");
6
6
  class LuxonDateTime {
7
7
  constructor(input) {
@@ -113,6 +113,40 @@ class LocalTimeLuxon extends LuxonDateTime {
113
113
  }
114
114
  exports.LocalTimeLuxon = LocalTimeLuxon;
115
115
  LocalTimeLuxon.format = 'HH:mm:ss';
116
+ class LocalDateTimeLuxon extends LuxonDateTime {
117
+ constructor(input) {
118
+ super(input);
119
+ }
120
+ static nowLocal(options) {
121
+ return new LocalDateTimeLuxon(luxon_1.DateTime.local(options));
122
+ }
123
+ static nowUtc() {
124
+ return new LocalDateTimeLuxon(luxon_1.DateTime.utc());
125
+ }
126
+ static fromISO(value, options) {
127
+ return new LocalDateTimeLuxon(luxon_1.DateTime.fromISO(value, Object.assign({ zone: luxon_1.FixedOffsetZone.utcInstance }, options)));
128
+ }
129
+ static fromFormat(value, format, options) {
130
+ return new LocalDateTimeLuxon(luxon_1.DateTime.fromFormat(value, format, Object.assign({ zone: luxon_1.FixedOffsetZone.utcInstance }, options)));
131
+ }
132
+ static fromJSDate(date, options) {
133
+ return new LocalDateTimeLuxon(luxon_1.DateTime.fromJSDate(date, Object.assign({ zone: luxon_1.FixedOffsetZone.utcInstance }, options)));
134
+ }
135
+ static fromMillis(millis, options) {
136
+ return new LocalDateTimeLuxon(luxon_1.DateTime.fromMillis(millis, Object.assign({ zone: luxon_1.FixedOffsetZone.utcInstance }, options)));
137
+ }
138
+ normalize(dateTime) {
139
+ return luxon_1.DateTime.utc(dateTime.year, dateTime.month, dateTime.day, dateTime.hour, dateTime.minute, dateTime.second);
140
+ }
141
+ wrap(fn) {
142
+ return new LocalDateTimeLuxon(fn(this.dateTime));
143
+ }
144
+ toJSON() {
145
+ return this.dateTime.toFormat(LocalDateTimeLuxon.format);
146
+ }
147
+ }
148
+ exports.LocalDateTimeLuxon = LocalDateTimeLuxon;
149
+ LocalDateTimeLuxon.format = "yyyy-MM-dd'T'HH:mm:ss";
116
150
  class DateTimeLuxon extends LuxonDateTime {
117
151
  constructor(input) {
118
152
  super(input);
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
- var _a, _b;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  const luxon_1 = require("luxon");
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');
4
+ const dt = luxon_1.DateTime.fromISO('2022-10-29T23:30:00').setZone(luxon_1.FixedOffsetZone.instance(-60), { keepLocalTime: true });
5
+ console.log(dt);
6
+ console.log(dt.setZone(luxon_1.FixedOffsetZone.utcInstance));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finnair/v-validation-luxon",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "private": false,
5
5
  "description": "Luxon validators",
6
6
  "main": "dist/index.js",
@@ -25,11 +25,11 @@
25
25
  "build": "tsc -b ."
26
26
  },
27
27
  "dependencies": {
28
- "@finnair/path": "^3.0.0",
29
- "@finnair/v-validation": "^3.0.0"
28
+ "@finnair/path": "^3.1.0",
29
+ "@finnair/v-validation": "^3.1.0"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "luxon": "^3.0.0"
33
33
  },
34
- "gitHead": "597b85f1fcef99722bccf47c6d30260973d6d88c"
34
+ "gitHead": "5182a63fa61cc1f5c8991e1482c5bbffe14798c3"
35
35
  }