valgen 4.2.0 → 4.2.2
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 +14 -0
- package/cjs/rules/is-date.js +5 -9
- package/esm/rules/is-date.js +5 -9
- package/package.json +1 -1
- package/typings/rules/is-date.d.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# v4.2.2
|
|
2
|
+
[2023-11-15]
|
|
3
|
+
|
|
4
|
+
### Changes
|
|
5
|
+
|
|
6
|
+
* Changed "trim" option ([`b5eff4f`](https://github.com/panates/valgen/commit/b5eff4ffd61eb78ea244dfe2c66ca86275b9578c))
|
|
7
|
+
|
|
8
|
+
# v4.2.1
|
|
9
|
+
[2023-11-15]
|
|
10
|
+
|
|
11
|
+
### Changes
|
|
12
|
+
|
|
13
|
+
* Fixed generating invalid date string ([`6407ac6`](https://github.com/panates/valgen/commit/6407ac6bd17bf84a8d031efe9b3998d58c5b7f8b))
|
|
14
|
+
|
|
1
15
|
# v4.2.0
|
|
2
16
|
[2023-11-15]
|
|
3
17
|
|
package/cjs/rules/is-date.js
CHANGED
|
@@ -74,13 +74,13 @@ function isDateString(options) {
|
|
|
74
74
|
s += '-' + m[3];
|
|
75
75
|
else
|
|
76
76
|
return s;
|
|
77
|
-
if (trim === '
|
|
77
|
+
if (trim === 'date' || !m[4])
|
|
78
78
|
return s;
|
|
79
79
|
s += 'T' + m[4];
|
|
80
|
-
if (trim === '
|
|
80
|
+
if (trim === 'time')
|
|
81
81
|
return s;
|
|
82
82
|
if (m[9])
|
|
83
|
-
s +=
|
|
83
|
+
s += m[9];
|
|
84
84
|
return s;
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -89,13 +89,9 @@ function isDateString(options) {
|
|
|
89
89
|
else if (input != null) {
|
|
90
90
|
const d = (0, dayjs_1.default)(input);
|
|
91
91
|
if (d.isValid()) {
|
|
92
|
-
if (
|
|
93
|
-
return input;
|
|
94
|
-
if (trim === 'timezone')
|
|
95
|
-
return d.millisecond() ? d.format('YYYY-MM-DDTHH:mm:ss.SSS') : d.format('YYYY-MM-DDTHH:mm:ss');
|
|
96
|
-
if (trim === 'time')
|
|
92
|
+
if (trim === 'date')
|
|
97
93
|
return d.format('YYYY-MM-DD');
|
|
98
|
-
return d.
|
|
94
|
+
return d.millisecond() ? d.format('YYYY-MM-DDTHH:mm:ss.SSS') : d.format('YYYY-MM-DDTHH:mm:ss');
|
|
99
95
|
}
|
|
100
96
|
}
|
|
101
97
|
context.fail(_this, `{{label}} is not a valid date string`, input, { ...options });
|
package/esm/rules/is-date.js
CHANGED
|
@@ -67,13 +67,13 @@ export function isDateString(options) {
|
|
|
67
67
|
s += '-' + m[3];
|
|
68
68
|
else
|
|
69
69
|
return s;
|
|
70
|
-
if (trim === '
|
|
70
|
+
if (trim === 'date' || !m[4])
|
|
71
71
|
return s;
|
|
72
72
|
s += 'T' + m[4];
|
|
73
|
-
if (trim === '
|
|
73
|
+
if (trim === 'time')
|
|
74
74
|
return s;
|
|
75
75
|
if (m[9])
|
|
76
|
-
s +=
|
|
76
|
+
s += m[9];
|
|
77
77
|
return s;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -82,13 +82,9 @@ export function isDateString(options) {
|
|
|
82
82
|
else if (input != null) {
|
|
83
83
|
const d = dayjs(input);
|
|
84
84
|
if (d.isValid()) {
|
|
85
|
-
if (
|
|
86
|
-
return input;
|
|
87
|
-
if (trim === 'timezone')
|
|
88
|
-
return d.millisecond() ? d.format('YYYY-MM-DDTHH:mm:ss.SSS') : d.format('YYYY-MM-DDTHH:mm:ss');
|
|
89
|
-
if (trim === 'time')
|
|
85
|
+
if (trim === 'date')
|
|
90
86
|
return d.format('YYYY-MM-DD');
|
|
91
|
-
return d.
|
|
87
|
+
return d.millisecond() ? d.format('YYYY-MM-DDTHH:mm:ss.SSS') : d.format('YYYY-MM-DDTHH:mm:ss');
|
|
92
88
|
}
|
|
93
89
|
}
|
|
94
90
|
context.fail(_this, `{{label}} is not a valid date string`, input, { ...options });
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@ export interface IsDateOptions extends ValidationOptions {
|
|
|
10
10
|
export declare function isDate(options?: IsDateOptions): import("../core/validator.js").Validator<Date, string | number | Date, import("../core/types.js").ExecutionOptions>;
|
|
11
11
|
export interface IsDateStringOptions extends ValidationOptions {
|
|
12
12
|
precision?: 'year' | 'month' | 'date' | 'time';
|
|
13
|
-
trim?: '
|
|
13
|
+
trim?: 'date' | 'time';
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Validates if value is DFS (date formatted string).
|