@finnair/v-validation-luxon 2.0.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 +11 -0
- package/dist/Vluxon.d.ts +1 -1
- package/dist/Vluxon.js +21 -23
- package/package.json +3 -3
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
|
+
# [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
|
+
|
|
6
17
|
# [2.0.0](https://github.com/finnair/v-validation/compare/v1.1.0...v2.0.0) (2022-09-08)
|
|
7
18
|
|
|
8
19
|
|
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):
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finnair/v-validation-luxon",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Luxon validators",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@finnair/path": "^2.0.0",
|
|
29
|
-
"@finnair/v-validation": "^
|
|
29
|
+
"@finnair/v-validation": "^3.0.0-alpha.0",
|
|
30
30
|
"luxon": "3.0.3"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/luxon": "3.0.1"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "f41f76dbe0365314dc15c07d3db2ad5a7b5e4109"
|
|
36
36
|
}
|