@optique/temporal 0.5.0-dev.79 → 0.5.0-dev.82
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/dist/index.cjs +9 -9
- package/dist/index.d.cts +109 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.js +9 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -49,7 +49,7 @@ function instant(options = {}) {
|
|
|
49
49
|
} catch {
|
|
50
50
|
return {
|
|
51
51
|
success: false,
|
|
52
|
-
error: __optique_core_message.message`Invalid instant: ${input}. Expected ISO 8601 format like ${"2020-01-23T17:04:36Z"}.`
|
|
52
|
+
error: options.errors?.invalidFormat ? typeof options.errors.invalidFormat === "function" ? options.errors.invalidFormat(input) : options.errors.invalidFormat : __optique_core_message.message`Invalid instant: ${input}. Expected ISO 8601 format like ${"2020-01-23T17:04:36Z"}.`
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
},
|
|
@@ -83,7 +83,7 @@ function duration(options = {}) {
|
|
|
83
83
|
} catch {
|
|
84
84
|
return {
|
|
85
85
|
success: false,
|
|
86
|
-
error: __optique_core_message.message`Invalid duration: ${input}. Expected ISO 8601 format like ${"PT1H30M"}.`
|
|
86
|
+
error: options.errors?.invalidFormat ? typeof options.errors.invalidFormat === "function" ? options.errors.invalidFormat(input) : options.errors.invalidFormat : __optique_core_message.message`Invalid duration: ${input}. Expected ISO 8601 format like ${"PT1H30M"}.`
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
},
|
|
@@ -116,7 +116,7 @@ function zonedDateTime(options = {}) {
|
|
|
116
116
|
} catch {
|
|
117
117
|
return {
|
|
118
118
|
success: false,
|
|
119
|
-
error: __optique_core_message.message`Invalid zoned datetime: ${input}. Expected ISO 8601 format with timezone like ${"2020-01-23T17:04:36+01:00[Europe/Paris]"}.`
|
|
119
|
+
error: options.errors?.invalidFormat ? typeof options.errors.invalidFormat === "function" ? options.errors.invalidFormat(input) : options.errors.invalidFormat : __optique_core_message.message`Invalid zoned datetime: ${input}. Expected ISO 8601 format with timezone like ${"2020-01-23T17:04:36+01:00[Europe/Paris]"}.`
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
122
|
},
|
|
@@ -149,7 +149,7 @@ function plainDate(options = {}) {
|
|
|
149
149
|
} catch {
|
|
150
150
|
return {
|
|
151
151
|
success: false,
|
|
152
|
-
error: __optique_core_message.message`Invalid date: ${input}. Expected ISO 8601 format like ${"2020-01-23"}.`
|
|
152
|
+
error: options.errors?.invalidFormat ? typeof options.errors.invalidFormat === "function" ? options.errors.invalidFormat(input) : options.errors.invalidFormat : __optique_core_message.message`Invalid date: ${input}. Expected ISO 8601 format like ${"2020-01-23"}.`
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
155
|
},
|
|
@@ -182,7 +182,7 @@ function plainTime(options = {}) {
|
|
|
182
182
|
} catch {
|
|
183
183
|
return {
|
|
184
184
|
success: false,
|
|
185
|
-
error: __optique_core_message.message`Invalid time: ${input}. Expected ISO 8601 format like ${"17:04:36"}.`
|
|
185
|
+
error: options.errors?.invalidFormat ? typeof options.errors.invalidFormat === "function" ? options.errors.invalidFormat(input) : options.errors.invalidFormat : __optique_core_message.message`Invalid time: ${input}. Expected ISO 8601 format like ${"17:04:36"}.`
|
|
186
186
|
};
|
|
187
187
|
}
|
|
188
188
|
},
|
|
@@ -215,7 +215,7 @@ function plainDateTime(options = {}) {
|
|
|
215
215
|
} catch {
|
|
216
216
|
return {
|
|
217
217
|
success: false,
|
|
218
|
-
error: __optique_core_message.message`Invalid datetime: ${input}. Expected ISO 8601 format like ${"2020-01-23T17:04:36"}.`
|
|
218
|
+
error: options.errors?.invalidFormat ? typeof options.errors.invalidFormat === "function" ? options.errors.invalidFormat(input) : options.errors.invalidFormat : __optique_core_message.message`Invalid datetime: ${input}. Expected ISO 8601 format like ${"2020-01-23T17:04:36"}.`
|
|
219
219
|
};
|
|
220
220
|
}
|
|
221
221
|
},
|
|
@@ -248,7 +248,7 @@ function plainYearMonth(options = {}) {
|
|
|
248
248
|
} catch {
|
|
249
249
|
return {
|
|
250
250
|
success: false,
|
|
251
|
-
error: __optique_core_message.message`Invalid year-month: ${input}. Expected ISO 8601 format like ${"2020-01"}.`
|
|
251
|
+
error: options.errors?.invalidFormat ? typeof options.errors.invalidFormat === "function" ? options.errors.invalidFormat(input) : options.errors.invalidFormat : __optique_core_message.message`Invalid year-month: ${input}. Expected ISO 8601 format like ${"2020-01"}.`
|
|
252
252
|
};
|
|
253
253
|
}
|
|
254
254
|
},
|
|
@@ -281,7 +281,7 @@ function plainMonthDay(options = {}) {
|
|
|
281
281
|
} catch {
|
|
282
282
|
return {
|
|
283
283
|
success: false,
|
|
284
|
-
error: __optique_core_message.message`Invalid month-day: ${input}. Expected ISO 8601 format like ${"--01-23"}.`
|
|
284
|
+
error: options.errors?.invalidFormat ? typeof options.errors.invalidFormat === "function" ? options.errors.invalidFormat(input) : options.errors.invalidFormat : __optique_core_message.message`Invalid month-day: ${input}. Expected ISO 8601 format like ${"--01-23"}.`
|
|
285
285
|
};
|
|
286
286
|
}
|
|
287
287
|
},
|
|
@@ -321,7 +321,7 @@ function timeZone(options = {}) {
|
|
|
321
321
|
} catch {
|
|
322
322
|
return {
|
|
323
323
|
success: false,
|
|
324
|
-
error: __optique_core_message.message`Invalid timezone identifier: ${input}. Must be a valid IANA timezone like "Asia/Seoul" or "UTC".`
|
|
324
|
+
error: options.errors?.invalidFormat ? typeof options.errors.invalidFormat === "function" ? options.errors.invalidFormat(input) : options.errors.invalidFormat : __optique_core_message.message`Invalid timezone identifier: ${input}. Must be a valid IANA timezone like "Asia/Seoul" or "UTC".`
|
|
325
325
|
};
|
|
326
326
|
}
|
|
327
327
|
},
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ValueParser } from "@optique/core/valueparser";
|
|
2
|
+
import { Message } from "@optique/core/message";
|
|
2
3
|
|
|
3
4
|
//#region src/index.d.ts
|
|
4
5
|
|
|
@@ -31,6 +32,18 @@ interface InstantOptions {
|
|
|
31
32
|
* @default `"TIMESTAMP"`
|
|
32
33
|
*/
|
|
33
34
|
readonly metavar?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Custom error messages for instant parsing failures.
|
|
37
|
+
* @since 0.5.0
|
|
38
|
+
*/
|
|
39
|
+
readonly errors?: {
|
|
40
|
+
/**
|
|
41
|
+
* Custom error message when input is not a valid instant format.
|
|
42
|
+
* Can be a static message or a function that receives the input.
|
|
43
|
+
* @since 0.5.0
|
|
44
|
+
*/
|
|
45
|
+
invalidFormat?: Message | ((input: string) => Message);
|
|
46
|
+
};
|
|
34
47
|
}
|
|
35
48
|
/**
|
|
36
49
|
* Options for creating a duration parser.
|
|
@@ -43,6 +56,18 @@ interface DurationOptions {
|
|
|
43
56
|
* @default `"DURATION"`
|
|
44
57
|
*/
|
|
45
58
|
readonly metavar?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Custom error messages for duration parsing failures.
|
|
61
|
+
* @since 0.5.0
|
|
62
|
+
*/
|
|
63
|
+
readonly errors?: {
|
|
64
|
+
/**
|
|
65
|
+
* Custom error message when input is not a valid duration format.
|
|
66
|
+
* Can be a static message or a function that receives the input.
|
|
67
|
+
* @since 0.5.0
|
|
68
|
+
*/
|
|
69
|
+
invalidFormat?: Message | ((input: string) => Message);
|
|
70
|
+
};
|
|
46
71
|
}
|
|
47
72
|
/**
|
|
48
73
|
* Options for creating a zoned datetime parser.
|
|
@@ -55,6 +80,18 @@ interface ZonedDateTimeOptions {
|
|
|
55
80
|
* @default `"ZONED_DATETIME"`
|
|
56
81
|
*/
|
|
57
82
|
readonly metavar?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Custom error messages for zoned datetime parsing failures.
|
|
85
|
+
* @since 0.5.0
|
|
86
|
+
*/
|
|
87
|
+
readonly errors?: {
|
|
88
|
+
/**
|
|
89
|
+
* Custom error message when input is not a valid zoned datetime format.
|
|
90
|
+
* Can be a static message or a function that receives the input.
|
|
91
|
+
* @since 0.5.0
|
|
92
|
+
*/
|
|
93
|
+
invalidFormat?: Message | ((input: string) => Message);
|
|
94
|
+
};
|
|
58
95
|
}
|
|
59
96
|
/**
|
|
60
97
|
* Options for creating a plain date parser.
|
|
@@ -67,6 +104,18 @@ interface PlainDateOptions {
|
|
|
67
104
|
* @default `"DATE"`
|
|
68
105
|
*/
|
|
69
106
|
readonly metavar?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Custom error messages for plain date parsing failures.
|
|
109
|
+
* @since 0.5.0
|
|
110
|
+
*/
|
|
111
|
+
readonly errors?: {
|
|
112
|
+
/**
|
|
113
|
+
* Custom error message when input is not a valid date format.
|
|
114
|
+
* Can be a static message or a function that receives the input.
|
|
115
|
+
* @since 0.5.0
|
|
116
|
+
*/
|
|
117
|
+
invalidFormat?: Message | ((input: string) => Message);
|
|
118
|
+
};
|
|
70
119
|
}
|
|
71
120
|
/**
|
|
72
121
|
* Options for creating a plain time parser.
|
|
@@ -79,6 +128,18 @@ interface PlainTimeOptions {
|
|
|
79
128
|
* @default `"TIME"`
|
|
80
129
|
*/
|
|
81
130
|
readonly metavar?: string;
|
|
131
|
+
/**
|
|
132
|
+
* Custom error messages for plain time parsing failures.
|
|
133
|
+
* @since 0.5.0
|
|
134
|
+
*/
|
|
135
|
+
readonly errors?: {
|
|
136
|
+
/**
|
|
137
|
+
* Custom error message when input is not a valid time format.
|
|
138
|
+
* Can be a static message or a function that receives the input.
|
|
139
|
+
* @since 0.5.0
|
|
140
|
+
*/
|
|
141
|
+
invalidFormat?: Message | ((input: string) => Message);
|
|
142
|
+
};
|
|
82
143
|
}
|
|
83
144
|
/**
|
|
84
145
|
* Options for creating a plain datetime parser.
|
|
@@ -91,6 +152,18 @@ interface PlainDateTimeOptions {
|
|
|
91
152
|
* @default `"DATETIME"`
|
|
92
153
|
*/
|
|
93
154
|
readonly metavar?: string;
|
|
155
|
+
/**
|
|
156
|
+
* Custom error messages for plain datetime parsing failures.
|
|
157
|
+
* @since 0.5.0
|
|
158
|
+
*/
|
|
159
|
+
readonly errors?: {
|
|
160
|
+
/**
|
|
161
|
+
* Custom error message when input is not a valid datetime format.
|
|
162
|
+
* Can be a static message or a function that receives the input.
|
|
163
|
+
* @since 0.5.0
|
|
164
|
+
*/
|
|
165
|
+
invalidFormat?: Message | ((input: string) => Message);
|
|
166
|
+
};
|
|
94
167
|
}
|
|
95
168
|
/**
|
|
96
169
|
* Options for creating a plain year-month parser.
|
|
@@ -103,6 +176,18 @@ interface PlainYearMonthOptions {
|
|
|
103
176
|
* @default `"YEAR-MONTH"`
|
|
104
177
|
*/
|
|
105
178
|
readonly metavar?: string;
|
|
179
|
+
/**
|
|
180
|
+
* Custom error messages for plain year-month parsing failures.
|
|
181
|
+
* @since 0.5.0
|
|
182
|
+
*/
|
|
183
|
+
readonly errors?: {
|
|
184
|
+
/**
|
|
185
|
+
* Custom error message when input is not a valid year-month format.
|
|
186
|
+
* Can be a static message or a function that receives the input.
|
|
187
|
+
* @since 0.5.0
|
|
188
|
+
*/
|
|
189
|
+
invalidFormat?: Message | ((input: string) => Message);
|
|
190
|
+
};
|
|
106
191
|
}
|
|
107
192
|
/**
|
|
108
193
|
* Options for creating a plain month-day parser.
|
|
@@ -115,6 +200,18 @@ interface PlainMonthDayOptions {
|
|
|
115
200
|
* @default `"--MONTH-DAY"`
|
|
116
201
|
*/
|
|
117
202
|
readonly metavar?: string;
|
|
203
|
+
/**
|
|
204
|
+
* Custom error messages for plain month-day parsing failures.
|
|
205
|
+
* @since 0.5.0
|
|
206
|
+
*/
|
|
207
|
+
readonly errors?: {
|
|
208
|
+
/**
|
|
209
|
+
* Custom error message when input is not a valid month-day format.
|
|
210
|
+
* Can be a static message or a function that receives the input.
|
|
211
|
+
* @since 0.5.0
|
|
212
|
+
*/
|
|
213
|
+
invalidFormat?: Message | ((input: string) => Message);
|
|
214
|
+
};
|
|
118
215
|
}
|
|
119
216
|
/**
|
|
120
217
|
* Options for creating a timezone parser.
|
|
@@ -127,6 +224,18 @@ interface TimeZoneOptions {
|
|
|
127
224
|
* @default `"TIMEZONE"`
|
|
128
225
|
*/
|
|
129
226
|
readonly metavar?: string;
|
|
227
|
+
/**
|
|
228
|
+
* Custom error messages for timezone parsing failures.
|
|
229
|
+
* @since 0.5.0
|
|
230
|
+
*/
|
|
231
|
+
readonly errors?: {
|
|
232
|
+
/**
|
|
233
|
+
* Custom error message when input is not a valid timezone identifier.
|
|
234
|
+
* Can be a static message or a function that receives the input.
|
|
235
|
+
* @since 0.5.0
|
|
236
|
+
*/
|
|
237
|
+
invalidFormat?: Message | ((input: string) => Message);
|
|
238
|
+
};
|
|
130
239
|
}
|
|
131
240
|
/**
|
|
132
241
|
* Creates a ValueParser for parsing Temporal.Instant from ISO 8601 strings.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import { Message } from "@optique/core/message";
|
|
2
3
|
import { ValueParser } from "@optique/core/valueparser";
|
|
3
4
|
|
|
4
5
|
//#region src/index.d.ts
|
|
@@ -32,6 +33,18 @@ interface InstantOptions {
|
|
|
32
33
|
* @default `"TIMESTAMP"`
|
|
33
34
|
*/
|
|
34
35
|
readonly metavar?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Custom error messages for instant parsing failures.
|
|
38
|
+
* @since 0.5.0
|
|
39
|
+
*/
|
|
40
|
+
readonly errors?: {
|
|
41
|
+
/**
|
|
42
|
+
* Custom error message when input is not a valid instant format.
|
|
43
|
+
* Can be a static message or a function that receives the input.
|
|
44
|
+
* @since 0.5.0
|
|
45
|
+
*/
|
|
46
|
+
invalidFormat?: Message | ((input: string) => Message);
|
|
47
|
+
};
|
|
35
48
|
}
|
|
36
49
|
/**
|
|
37
50
|
* Options for creating a duration parser.
|
|
@@ -44,6 +57,18 @@ interface DurationOptions {
|
|
|
44
57
|
* @default `"DURATION"`
|
|
45
58
|
*/
|
|
46
59
|
readonly metavar?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Custom error messages for duration parsing failures.
|
|
62
|
+
* @since 0.5.0
|
|
63
|
+
*/
|
|
64
|
+
readonly errors?: {
|
|
65
|
+
/**
|
|
66
|
+
* Custom error message when input is not a valid duration format.
|
|
67
|
+
* Can be a static message or a function that receives the input.
|
|
68
|
+
* @since 0.5.0
|
|
69
|
+
*/
|
|
70
|
+
invalidFormat?: Message | ((input: string) => Message);
|
|
71
|
+
};
|
|
47
72
|
}
|
|
48
73
|
/**
|
|
49
74
|
* Options for creating a zoned datetime parser.
|
|
@@ -56,6 +81,18 @@ interface ZonedDateTimeOptions {
|
|
|
56
81
|
* @default `"ZONED_DATETIME"`
|
|
57
82
|
*/
|
|
58
83
|
readonly metavar?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Custom error messages for zoned datetime parsing failures.
|
|
86
|
+
* @since 0.5.0
|
|
87
|
+
*/
|
|
88
|
+
readonly errors?: {
|
|
89
|
+
/**
|
|
90
|
+
* Custom error message when input is not a valid zoned datetime format.
|
|
91
|
+
* Can be a static message or a function that receives the input.
|
|
92
|
+
* @since 0.5.0
|
|
93
|
+
*/
|
|
94
|
+
invalidFormat?: Message | ((input: string) => Message);
|
|
95
|
+
};
|
|
59
96
|
}
|
|
60
97
|
/**
|
|
61
98
|
* Options for creating a plain date parser.
|
|
@@ -68,6 +105,18 @@ interface PlainDateOptions {
|
|
|
68
105
|
* @default `"DATE"`
|
|
69
106
|
*/
|
|
70
107
|
readonly metavar?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Custom error messages for plain date parsing failures.
|
|
110
|
+
* @since 0.5.0
|
|
111
|
+
*/
|
|
112
|
+
readonly errors?: {
|
|
113
|
+
/**
|
|
114
|
+
* Custom error message when input is not a valid date format.
|
|
115
|
+
* Can be a static message or a function that receives the input.
|
|
116
|
+
* @since 0.5.0
|
|
117
|
+
*/
|
|
118
|
+
invalidFormat?: Message | ((input: string) => Message);
|
|
119
|
+
};
|
|
71
120
|
}
|
|
72
121
|
/**
|
|
73
122
|
* Options for creating a plain time parser.
|
|
@@ -80,6 +129,18 @@ interface PlainTimeOptions {
|
|
|
80
129
|
* @default `"TIME"`
|
|
81
130
|
*/
|
|
82
131
|
readonly metavar?: string;
|
|
132
|
+
/**
|
|
133
|
+
* Custom error messages for plain time parsing failures.
|
|
134
|
+
* @since 0.5.0
|
|
135
|
+
*/
|
|
136
|
+
readonly errors?: {
|
|
137
|
+
/**
|
|
138
|
+
* Custom error message when input is not a valid time format.
|
|
139
|
+
* Can be a static message or a function that receives the input.
|
|
140
|
+
* @since 0.5.0
|
|
141
|
+
*/
|
|
142
|
+
invalidFormat?: Message | ((input: string) => Message);
|
|
143
|
+
};
|
|
83
144
|
}
|
|
84
145
|
/**
|
|
85
146
|
* Options for creating a plain datetime parser.
|
|
@@ -92,6 +153,18 @@ interface PlainDateTimeOptions {
|
|
|
92
153
|
* @default `"DATETIME"`
|
|
93
154
|
*/
|
|
94
155
|
readonly metavar?: string;
|
|
156
|
+
/**
|
|
157
|
+
* Custom error messages for plain datetime parsing failures.
|
|
158
|
+
* @since 0.5.0
|
|
159
|
+
*/
|
|
160
|
+
readonly errors?: {
|
|
161
|
+
/**
|
|
162
|
+
* Custom error message when input is not a valid datetime format.
|
|
163
|
+
* Can be a static message or a function that receives the input.
|
|
164
|
+
* @since 0.5.0
|
|
165
|
+
*/
|
|
166
|
+
invalidFormat?: Message | ((input: string) => Message);
|
|
167
|
+
};
|
|
95
168
|
}
|
|
96
169
|
/**
|
|
97
170
|
* Options for creating a plain year-month parser.
|
|
@@ -104,6 +177,18 @@ interface PlainYearMonthOptions {
|
|
|
104
177
|
* @default `"YEAR-MONTH"`
|
|
105
178
|
*/
|
|
106
179
|
readonly metavar?: string;
|
|
180
|
+
/**
|
|
181
|
+
* Custom error messages for plain year-month parsing failures.
|
|
182
|
+
* @since 0.5.0
|
|
183
|
+
*/
|
|
184
|
+
readonly errors?: {
|
|
185
|
+
/**
|
|
186
|
+
* Custom error message when input is not a valid year-month format.
|
|
187
|
+
* Can be a static message or a function that receives the input.
|
|
188
|
+
* @since 0.5.0
|
|
189
|
+
*/
|
|
190
|
+
invalidFormat?: Message | ((input: string) => Message);
|
|
191
|
+
};
|
|
107
192
|
}
|
|
108
193
|
/**
|
|
109
194
|
* Options for creating a plain month-day parser.
|
|
@@ -116,6 +201,18 @@ interface PlainMonthDayOptions {
|
|
|
116
201
|
* @default `"--MONTH-DAY"`
|
|
117
202
|
*/
|
|
118
203
|
readonly metavar?: string;
|
|
204
|
+
/**
|
|
205
|
+
* Custom error messages for plain month-day parsing failures.
|
|
206
|
+
* @since 0.5.0
|
|
207
|
+
*/
|
|
208
|
+
readonly errors?: {
|
|
209
|
+
/**
|
|
210
|
+
* Custom error message when input is not a valid month-day format.
|
|
211
|
+
* Can be a static message or a function that receives the input.
|
|
212
|
+
* @since 0.5.0
|
|
213
|
+
*/
|
|
214
|
+
invalidFormat?: Message | ((input: string) => Message);
|
|
215
|
+
};
|
|
119
216
|
}
|
|
120
217
|
/**
|
|
121
218
|
* Options for creating a timezone parser.
|
|
@@ -128,6 +225,18 @@ interface TimeZoneOptions {
|
|
|
128
225
|
* @default `"TIMEZONE"`
|
|
129
226
|
*/
|
|
130
227
|
readonly metavar?: string;
|
|
228
|
+
/**
|
|
229
|
+
* Custom error messages for timezone parsing failures.
|
|
230
|
+
* @since 0.5.0
|
|
231
|
+
*/
|
|
232
|
+
readonly errors?: {
|
|
233
|
+
/**
|
|
234
|
+
* Custom error message when input is not a valid timezone identifier.
|
|
235
|
+
* Can be a static message or a function that receives the input.
|
|
236
|
+
* @since 0.5.0
|
|
237
|
+
*/
|
|
238
|
+
invalidFormat?: Message | ((input: string) => Message);
|
|
239
|
+
};
|
|
131
240
|
}
|
|
132
241
|
/**
|
|
133
242
|
* Creates a ValueParser for parsing Temporal.Instant from ISO 8601 strings.
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,7 @@ function instant(options = {}) {
|
|
|
26
26
|
} catch {
|
|
27
27
|
return {
|
|
28
28
|
success: false,
|
|
29
|
-
error: message`Invalid instant: ${input}. Expected ISO 8601 format like ${"2020-01-23T17:04:36Z"}.`
|
|
29
|
+
error: options.errors?.invalidFormat ? typeof options.errors.invalidFormat === "function" ? options.errors.invalidFormat(input) : options.errors.invalidFormat : message`Invalid instant: ${input}. Expected ISO 8601 format like ${"2020-01-23T17:04:36Z"}.`
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
},
|
|
@@ -60,7 +60,7 @@ function duration(options = {}) {
|
|
|
60
60
|
} catch {
|
|
61
61
|
return {
|
|
62
62
|
success: false,
|
|
63
|
-
error: message`Invalid duration: ${input}. Expected ISO 8601 format like ${"PT1H30M"}.`
|
|
63
|
+
error: options.errors?.invalidFormat ? typeof options.errors.invalidFormat === "function" ? options.errors.invalidFormat(input) : options.errors.invalidFormat : message`Invalid duration: ${input}. Expected ISO 8601 format like ${"PT1H30M"}.`
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
66
|
},
|
|
@@ -93,7 +93,7 @@ function zonedDateTime(options = {}) {
|
|
|
93
93
|
} catch {
|
|
94
94
|
return {
|
|
95
95
|
success: false,
|
|
96
|
-
error: message`Invalid zoned datetime: ${input}. Expected ISO 8601 format with timezone like ${"2020-01-23T17:04:36+01:00[Europe/Paris]"}.`
|
|
96
|
+
error: options.errors?.invalidFormat ? typeof options.errors.invalidFormat === "function" ? options.errors.invalidFormat(input) : options.errors.invalidFormat : message`Invalid zoned datetime: ${input}. Expected ISO 8601 format with timezone like ${"2020-01-23T17:04:36+01:00[Europe/Paris]"}.`
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
},
|
|
@@ -126,7 +126,7 @@ function plainDate(options = {}) {
|
|
|
126
126
|
} catch {
|
|
127
127
|
return {
|
|
128
128
|
success: false,
|
|
129
|
-
error: message`Invalid date: ${input}. Expected ISO 8601 format like ${"2020-01-23"}.`
|
|
129
|
+
error: options.errors?.invalidFormat ? typeof options.errors.invalidFormat === "function" ? options.errors.invalidFormat(input) : options.errors.invalidFormat : message`Invalid date: ${input}. Expected ISO 8601 format like ${"2020-01-23"}.`
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
132
|
},
|
|
@@ -159,7 +159,7 @@ function plainTime(options = {}) {
|
|
|
159
159
|
} catch {
|
|
160
160
|
return {
|
|
161
161
|
success: false,
|
|
162
|
-
error: message`Invalid time: ${input}. Expected ISO 8601 format like ${"17:04:36"}.`
|
|
162
|
+
error: options.errors?.invalidFormat ? typeof options.errors.invalidFormat === "function" ? options.errors.invalidFormat(input) : options.errors.invalidFormat : message`Invalid time: ${input}. Expected ISO 8601 format like ${"17:04:36"}.`
|
|
163
163
|
};
|
|
164
164
|
}
|
|
165
165
|
},
|
|
@@ -192,7 +192,7 @@ function plainDateTime(options = {}) {
|
|
|
192
192
|
} catch {
|
|
193
193
|
return {
|
|
194
194
|
success: false,
|
|
195
|
-
error: message`Invalid datetime: ${input}. Expected ISO 8601 format like ${"2020-01-23T17:04:36"}.`
|
|
195
|
+
error: options.errors?.invalidFormat ? typeof options.errors.invalidFormat === "function" ? options.errors.invalidFormat(input) : options.errors.invalidFormat : message`Invalid datetime: ${input}. Expected ISO 8601 format like ${"2020-01-23T17:04:36"}.`
|
|
196
196
|
};
|
|
197
197
|
}
|
|
198
198
|
},
|
|
@@ -225,7 +225,7 @@ function plainYearMonth(options = {}) {
|
|
|
225
225
|
} catch {
|
|
226
226
|
return {
|
|
227
227
|
success: false,
|
|
228
|
-
error: message`Invalid year-month: ${input}. Expected ISO 8601 format like ${"2020-01"}.`
|
|
228
|
+
error: options.errors?.invalidFormat ? typeof options.errors.invalidFormat === "function" ? options.errors.invalidFormat(input) : options.errors.invalidFormat : message`Invalid year-month: ${input}. Expected ISO 8601 format like ${"2020-01"}.`
|
|
229
229
|
};
|
|
230
230
|
}
|
|
231
231
|
},
|
|
@@ -258,7 +258,7 @@ function plainMonthDay(options = {}) {
|
|
|
258
258
|
} catch {
|
|
259
259
|
return {
|
|
260
260
|
success: false,
|
|
261
|
-
error: message`Invalid month-day: ${input}. Expected ISO 8601 format like ${"--01-23"}.`
|
|
261
|
+
error: options.errors?.invalidFormat ? typeof options.errors.invalidFormat === "function" ? options.errors.invalidFormat(input) : options.errors.invalidFormat : message`Invalid month-day: ${input}. Expected ISO 8601 format like ${"--01-23"}.`
|
|
262
262
|
};
|
|
263
263
|
}
|
|
264
264
|
},
|
|
@@ -298,7 +298,7 @@ function timeZone(options = {}) {
|
|
|
298
298
|
} catch {
|
|
299
299
|
return {
|
|
300
300
|
success: false,
|
|
301
|
-
error: message`Invalid timezone identifier: ${input}. Must be a valid IANA timezone like "Asia/Seoul" or "UTC".`
|
|
301
|
+
error: options.errors?.invalidFormat ? typeof options.errors.invalidFormat === "function" ? options.errors.invalidFormat(input) : options.errors.invalidFormat : message`Invalid timezone identifier: ${input}. Must be a valid IANA timezone like "Asia/Seoul" or "UTC".`
|
|
302
302
|
};
|
|
303
303
|
}
|
|
304
304
|
},
|