valgen 5.17.0 → 5.17.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 +13 -1
- package/cjs/rules/type-rules/is-date.js +8 -25
- package/esm/rules/type-rules/is-date.js +8 -25
- package/package.json +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
## Changelog
|
|
2
2
|
|
|
3
|
-
### [v5.17.
|
|
3
|
+
### [v5.17.2](https://github.com/panates/valgen/compare/v5.17.1...v5.17.2) -
|
|
4
|
+
|
|
5
|
+
#### 🛠 Refactoring and Updates
|
|
6
|
+
|
|
7
|
+
- refactor: Minor date rule optimization @Eray Hanoğlu
|
|
8
|
+
|
|
9
|
+
### [v5.17.1](https://github.com/panates/valgen/compare/v5.17.0...v5.17.1) - 24 July 2025
|
|
10
|
+
|
|
11
|
+
#### 🪲 Fixes
|
|
12
|
+
|
|
13
|
+
- fix: isDate milliseconds padding @Eray Hanoğlu
|
|
14
|
+
|
|
15
|
+
### [v5.17.0](https://github.com/panates/valgen/compare/v5.16.0...v5.17.0) - 24 July 2025
|
|
4
16
|
|
|
5
17
|
#### 🪲 Fixes
|
|
6
18
|
|
|
@@ -71,14 +71,15 @@ function coerceDateString(input, precision) {
|
|
|
71
71
|
if (input instanceof Date || typeof input === 'number') {
|
|
72
72
|
const d = typeof input === 'number' ? new Date(input) : input;
|
|
73
73
|
dateParts = [
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
String(d.getMilliseconds()),
|
|
74
|
+
String(d.getFullYear()).padStart(4, '0'),
|
|
75
|
+
String(d.getMonth() + 1).padStart(2, '0'),
|
|
76
|
+
String(d.getDate()).padStart(2, '0'),
|
|
77
|
+
String(d.getHours()).padStart(2, '0'),
|
|
78
|
+
String(d.getMinutes()).padStart(2, '0'),
|
|
79
|
+
String(d.getSeconds()).padStart(2, '0'),
|
|
81
80
|
];
|
|
81
|
+
if (d.getMilliseconds() > 0)
|
|
82
|
+
dateParts.push(String(d.getMilliseconds()).padStart(3, '0'));
|
|
82
83
|
}
|
|
83
84
|
else if (typeof input === 'string') {
|
|
84
85
|
const d = datefns.parseISO(input);
|
|
@@ -131,24 +132,6 @@ const PRECISION_INDEX = {
|
|
|
131
132
|
ms: 7,
|
|
132
133
|
tz: 8,
|
|
133
134
|
};
|
|
134
|
-
/**
|
|
135
|
-
* Pads a string to the specified length
|
|
136
|
-
* @param value - The string to pad
|
|
137
|
-
* @param len - The desired total length of the resulting string
|
|
138
|
-
* @param padChar - The character to pad with (defaults to '0')
|
|
139
|
-
* @returns The padded string
|
|
140
|
-
*/
|
|
141
|
-
function padString(value, len, padChar = '0') {
|
|
142
|
-
// Convert value to string if it's a number
|
|
143
|
-
const str = String(value);
|
|
144
|
-
// Return original string if it's already longer or equal to target length
|
|
145
|
-
if (str.length >= len) {
|
|
146
|
-
return str;
|
|
147
|
-
}
|
|
148
|
-
// Create padding and concatenate with original string
|
|
149
|
-
const padding = padChar.repeat(len - str.length);
|
|
150
|
-
return padding + str;
|
|
151
|
-
}
|
|
152
135
|
function setPrecision(d, precision) {
|
|
153
136
|
switch (precision) {
|
|
154
137
|
case 'year': {
|
|
@@ -66,14 +66,15 @@ function coerceDateString(input, precision) {
|
|
|
66
66
|
if (input instanceof Date || typeof input === 'number') {
|
|
67
67
|
const d = typeof input === 'number' ? new Date(input) : input;
|
|
68
68
|
dateParts = [
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
String(d.getMilliseconds()),
|
|
69
|
+
String(d.getFullYear()).padStart(4, '0'),
|
|
70
|
+
String(d.getMonth() + 1).padStart(2, '0'),
|
|
71
|
+
String(d.getDate()).padStart(2, '0'),
|
|
72
|
+
String(d.getHours()).padStart(2, '0'),
|
|
73
|
+
String(d.getMinutes()).padStart(2, '0'),
|
|
74
|
+
String(d.getSeconds()).padStart(2, '0'),
|
|
76
75
|
];
|
|
76
|
+
if (d.getMilliseconds() > 0)
|
|
77
|
+
dateParts.push(String(d.getMilliseconds()).padStart(3, '0'));
|
|
77
78
|
}
|
|
78
79
|
else if (typeof input === 'string') {
|
|
79
80
|
const d = datefns.parseISO(input);
|
|
@@ -126,24 +127,6 @@ const PRECISION_INDEX = {
|
|
|
126
127
|
ms: 7,
|
|
127
128
|
tz: 8,
|
|
128
129
|
};
|
|
129
|
-
/**
|
|
130
|
-
* Pads a string to the specified length
|
|
131
|
-
* @param value - The string to pad
|
|
132
|
-
* @param len - The desired total length of the resulting string
|
|
133
|
-
* @param padChar - The character to pad with (defaults to '0')
|
|
134
|
-
* @returns The padded string
|
|
135
|
-
*/
|
|
136
|
-
function padString(value, len, padChar = '0') {
|
|
137
|
-
// Convert value to string if it's a number
|
|
138
|
-
const str = String(value);
|
|
139
|
-
// Return original string if it's already longer or equal to target length
|
|
140
|
-
if (str.length >= len) {
|
|
141
|
-
return str;
|
|
142
|
-
}
|
|
143
|
-
// Create padding and concatenate with original string
|
|
144
|
-
const padding = padChar.repeat(len - str.length);
|
|
145
|
-
return padding + str;
|
|
146
|
-
}
|
|
147
130
|
function setPrecision(d, precision) {
|
|
148
131
|
switch (precision) {
|
|
149
132
|
case 'year': {
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valgen",
|
|
3
3
|
"description": "Fast runtime type validator, converter and io (encoding/decoding) library",
|
|
4
|
-
"version": "5.17.
|
|
4
|
+
"version": "5.17.2",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@browsery/validator": "^13.12.0-r3",
|
|
9
|
-
"@js-temporal/polyfill": "^0.5.1",
|
|
10
9
|
"date-fns": "^4.1.0",
|
|
11
10
|
"reflect-metadata": "^0.2.2",
|
|
12
11
|
"ts-gems": "^3.11.3",
|