@finnair/v-validation-luxon 4.1.0 → 4.2.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 +11 -0
- package/README.md +16 -15
- package/dist/Vluxon.d.ts +4 -0
- package/dist/Vluxon.js +22 -1
- package/dist/test-luxon.js +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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
|
+
# [4.2.0](https://github.com/finnair/v-validation/compare/v4.1.0...v4.2.0) (2023-01-24)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Support ISO 8601 time string as Duration ([#89](https://github.com/finnair/v-validation/issues/89)) ([75fb154](https://github.com/finnair/v-validation/commit/75fb154fa5283e7a51d3301097c7ed759beeabd8))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [4.1.0](https://github.com/finnair/v-validation/compare/v4.0.0...v4.1.0) (2022-11-22)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @finnair/v-validation-luxon
|
package/README.md
CHANGED
|
@@ -74,18 +74,19 @@ DateTime instance which is public readonly fiedl. However there are a few conven
|
|
|
74
74
|
|
|
75
75
|
## Build-in Validators
|
|
76
76
|
|
|
77
|
-
| Vluxon. | Format
|
|
78
|
-
| ------------------- |
|
|
79
|
-
| localDate | `yyyy-MM-dd`
|
|
80
|
-
| localTime | `HH:mm:ss`
|
|
81
|
-
| dateTime | `yyyy-MM-ddTHH:mm:ssZ`
|
|
82
|
-
| dateTimeUtc | `yyyy-MM-ddTHH:mm:ssZ`
|
|
83
|
-
| dateTimeMillis | `yyyy-MM-ddTHH:mm:ss.SSSZ`
|
|
84
|
-
| dateTimeMillisUtc | `yyyy-MM-ddTHH:mm:ss.SSSZ`
|
|
85
|
-
| dateTimeFromISO | Any ISO
|
|
86
|
-
| dateTimeFromRFC2822 | RFC2822
|
|
87
|
-
| dateTimeFromHTTP | HTTP date-time
|
|
88
|
-
| dateTimeFromSQL | SQL date-time
|
|
89
|
-
| dateTimeFromSeconds | Unix timestamp (number)
|
|
90
|
-
| dateTimeFromMillis | Unix timestamp (number)
|
|
91
|
-
| duration | ISO 8601 Duration
|
|
77
|
+
| Vluxon. | Format | Description |
|
|
78
|
+
| ------------------- | -------------------------------- | --------------------------------------------------------- |
|
|
79
|
+
| localDate | `yyyy-MM-dd` | Local date (time normalized to midninght UTC). |
|
|
80
|
+
| localTime | `HH:mm:ss` | Local time (date normalized to 1970-01-01). |
|
|
81
|
+
| dateTime | `yyyy-MM-ddTHH:mm:ssZ` | Date and time in local (parsed) time zone. |
|
|
82
|
+
| dateTimeUtc | `yyyy-MM-ddTHH:mm:ssZ` | Date and time in UTC time zone. |
|
|
83
|
+
| dateTimeMillis | `yyyy-MM-ddTHH:mm:ss.SSSZ` | Date and time with millis in local (parsed) time zone. |
|
|
84
|
+
| dateTimeMillisUtc | `yyyy-MM-ddTHH:mm:ss.SSSZ` | Date and time with millis in UTC time zone. |
|
|
85
|
+
| dateTimeFromISO | Any ISO | Plain Luxon DateTime from ISO format. |
|
|
86
|
+
| dateTimeFromRFC2822 | RFC2822 | Plain Luxon DateTime from RFC2822 format. |
|
|
87
|
+
| dateTimeFromHTTP | HTTP date-time | Plain Luxon DateTime from HTTP format. |
|
|
88
|
+
| dateTimeFromSQL | SQL date-time | Plain Luxon DateTime from SQL format. |
|
|
89
|
+
| dateTimeFromSeconds | Unix timestamp (number) | Plain Luxon DateTime from Unix timestamp in seconds. |
|
|
90
|
+
| dateTimeFromMillis | Unix timestamp (number) | Plain Luxon DateTime from Unix timestamp in milliseconds. |
|
|
91
|
+
| duration | ISO 8601 Duration | Luxon `Duration.fromISO` with pattern validation. |
|
|
92
|
+
| timeDuration | ISO 8601 time string as Duration | Luxon `Duration.fromISOTime`. |
|
package/dist/Vluxon.d.ts
CHANGED
|
@@ -38,6 +38,9 @@ declare function dateTimeFromSeconds(options?: DateTimeJSOptions): import("@finn
|
|
|
38
38
|
export declare class DurationValidator extends Validator {
|
|
39
39
|
validatePath(value: any, path: Path, ctx: ValidationContext): Promise<ValidationResult>;
|
|
40
40
|
}
|
|
41
|
+
export declare class TimeDurationValidator extends Validator {
|
|
42
|
+
validatePath(value: any, path: Path, ctx: ValidationContext): Promise<ValidationResult>;
|
|
43
|
+
}
|
|
41
44
|
export declare const Vluxon: {
|
|
42
45
|
localDate: typeof localDate;
|
|
43
46
|
localTime: typeof localTime;
|
|
@@ -53,5 +56,6 @@ export declare const Vluxon: {
|
|
|
53
56
|
dateTimeFromSeconds: typeof dateTimeFromSeconds;
|
|
54
57
|
dateTimeFromMillis: typeof dateTimeFromMillis;
|
|
55
58
|
duration: () => DurationValidator;
|
|
59
|
+
timeDuration: () => TimeDurationValidator;
|
|
56
60
|
};
|
|
57
61
|
export {};
|
package/dist/Vluxon.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Vluxon = exports.DurationValidator = exports.validateLuxonNumber = exports.LuxonValidator = void 0;
|
|
12
|
+
exports.Vluxon = exports.TimeDurationValidator = exports.DurationValidator = exports.validateLuxonNumber = exports.LuxonValidator = void 0;
|
|
13
13
|
const v_validation_1 = require("@finnair/v-validation");
|
|
14
14
|
const luxon_1 = require("luxon");
|
|
15
15
|
const luxon_2 = require("./luxon");
|
|
@@ -197,6 +197,26 @@ class DurationValidator extends v_validation_1.Validator {
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
exports.DurationValidator = DurationValidator;
|
|
200
|
+
class TimeDurationValidator extends v_validation_1.Validator {
|
|
201
|
+
validatePath(value, path, ctx) {
|
|
202
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
203
|
+
if ((0, v_validation_1.isNullOrUndefined)(value)) {
|
|
204
|
+
return ctx.failure(v_validation_1.defaultViolations.notNull(path), value);
|
|
205
|
+
}
|
|
206
|
+
else if (luxon_1.Duration.isDuration(value)) {
|
|
207
|
+
return ctx.success(value);
|
|
208
|
+
}
|
|
209
|
+
else if ((0, v_validation_1.isString)(value)) {
|
|
210
|
+
const duration = luxon_1.Duration.fromISOTime(value);
|
|
211
|
+
if (duration.isValid) {
|
|
212
|
+
return ctx.success(duration);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return ctx.failure(new v_validation_1.TypeMismatch(path, 'TimeDuration', value), value);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
exports.TimeDurationValidator = TimeDurationValidator;
|
|
200
220
|
exports.Vluxon = {
|
|
201
221
|
// DateTime wrapper validators
|
|
202
222
|
localDate,
|
|
@@ -214,5 +234,6 @@ exports.Vluxon = {
|
|
|
214
234
|
dateTimeFromSeconds,
|
|
215
235
|
dateTimeFromMillis,
|
|
216
236
|
duration: () => new DurationValidator(),
|
|
237
|
+
timeDuration: () => new TimeDurationValidator(),
|
|
217
238
|
};
|
|
218
239
|
Object.freeze(exports.Vluxon);
|
package/dist/test-luxon.js
CHANGED
|
@@ -4,3 +4,4 @@ const luxon_1 = require("luxon");
|
|
|
4
4
|
const dt = luxon_1.DateTime.fromISO('2022-10-29T23:30:00').setZone(luxon_1.FixedOffsetZone.instance(-60), { keepLocalTime: true });
|
|
5
5
|
console.log(dt);
|
|
6
6
|
console.log(dt.setZone(luxon_1.FixedOffsetZone.utcInstance));
|
|
7
|
+
console.log(luxon_1.Duration.fromISOTime('000900').toJSON());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finnair/v-validation-luxon",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Luxon validators",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"luxon": "^3.0.0"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "1a9091a370951283c32bc5c6f3770399e7afb6df"
|
|
35
35
|
}
|