@optique/core 0.5.0-dev.79 → 0.5.0-dev.80

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.
@@ -30,7 +30,7 @@ function choice(values, options = {}) {
30
30
  const index = normalizedValues.indexOf(normalizedInput);
31
31
  if (index < 0) return {
32
32
  success: false,
33
- error: require_message.message`Expected one of ${values.join(", ")}, but got ${input}.`
33
+ error: options.errors?.invalidChoice ? typeof options.errors.invalidChoice === "function" ? options.errors.invalidChoice(input, values) : options.errors.invalidChoice : require_message.message`Expected one of ${values.join(", ")}, but got ${input}.`
34
34
  };
35
35
  return {
36
36
  success: true,
@@ -57,7 +57,7 @@ function string(options = {}) {
57
57
  parse(input) {
58
58
  if (options.pattern != null && !options.pattern.test(input)) return {
59
59
  success: false,
60
- error: require_message.message`Expected a string matching pattern ${require_message.text(options.pattern.source)}, but got ${input}.`
60
+ error: options.errors?.patternMismatch ? typeof options.errors.patternMismatch === "function" ? options.errors.patternMismatch(input, options.pattern) : options.errors.patternMismatch : require_message.message`Expected a string matching pattern ${require_message.text(options.pattern.source)}, but got ${input}.`
61
61
  };
62
62
  return {
63
63
  success: true,
@@ -112,17 +112,17 @@ function integer(options) {
112
112
  } catch (e) {
113
113
  if (e instanceof SyntaxError) return {
114
114
  success: false,
115
- error: require_message.message`Expected a valid integer, but got ${input}.`
115
+ error: options.errors?.invalidInteger ? typeof options.errors.invalidInteger === "function" ? options.errors.invalidInteger(input) : options.errors.invalidInteger : require_message.message`Expected a valid integer, but got ${input}.`
116
116
  };
117
117
  throw e;
118
118
  }
119
119
  if (options.min != null && value < options.min) return {
120
120
  success: false,
121
- error: require_message.message`Expected a value greater than or equal to ${require_message.text(options.min.toLocaleString("en"))}, but got ${input}.`
121
+ error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value, options.min) : options.errors.belowMinimum : require_message.message`Expected a value greater than or equal to ${require_message.text(options.min.toLocaleString("en"))}, but got ${input}.`
122
122
  };
123
123
  else if (options.max != null && value > options.max) return {
124
124
  success: false,
125
- error: require_message.message`Expected a value less than or equal to ${require_message.text(options.max.toLocaleString("en"))}, but got ${input}.`
125
+ error: options.errors?.aboveMaximum ? typeof options.errors.aboveMaximum === "function" ? options.errors.aboveMaximum(value, options.max) : options.errors.aboveMaximum : require_message.message`Expected a value less than or equal to ${require_message.text(options.max.toLocaleString("en"))}, but got ${input}.`
126
126
  };
127
127
  return {
128
128
  success: true,
@@ -138,16 +138,16 @@ function integer(options) {
138
138
  parse(input) {
139
139
  if (!input.match(/^\d+$/)) return {
140
140
  success: false,
141
- error: require_message.message`Expected a valid integer, but got ${input}.`
141
+ error: options?.errors?.invalidInteger ? typeof options.errors.invalidInteger === "function" ? options.errors.invalidInteger(input) : options.errors.invalidInteger : require_message.message`Expected a valid integer, but got ${input}.`
142
142
  };
143
143
  const value = Number.parseInt(input);
144
144
  if (options?.min != null && value < options.min) return {
145
145
  success: false,
146
- error: require_message.message`Expected a value greater than or equal to ${require_message.text(options.min.toLocaleString("en"))}, but got ${input}.`
146
+ error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value, options.min) : options.errors.belowMinimum : require_message.message`Expected a value greater than or equal to ${require_message.text(options.min.toLocaleString("en"))}, but got ${input}.`
147
147
  };
148
148
  else if (options?.max != null && value > options.max) return {
149
149
  success: false,
150
- error: require_message.message`Expected a value less than or equal to ${require_message.text(options.max.toLocaleString("en"))}, but got ${input}.`
150
+ error: options.errors?.aboveMaximum ? typeof options.errors.aboveMaximum === "function" ? options.errors.aboveMaximum(value, options.max) : options.errors.aboveMaximum : require_message.message`Expected a value less than or equal to ${require_message.text(options.max.toLocaleString("en"))}, but got ${input}.`
151
151
  };
152
152
  return {
153
153
  success: true,
@@ -182,19 +182,19 @@ function float(options = {}) {
182
182
  value = Number(input);
183
183
  if (Number.isNaN(value)) return {
184
184
  success: false,
185
- error: require_message.message`Expected a valid number, but got ${input}.`
185
+ error: options.errors?.invalidNumber ? typeof options.errors.invalidNumber === "function" ? options.errors.invalidNumber(input) : options.errors.invalidNumber : require_message.message`Expected a valid number, but got ${input}.`
186
186
  };
187
187
  } else return {
188
188
  success: false,
189
- error: require_message.message`Expected a valid number, but got ${input}.`
189
+ error: options.errors?.invalidNumber ? typeof options.errors.invalidNumber === "function" ? options.errors.invalidNumber(input) : options.errors.invalidNumber : require_message.message`Expected a valid number, but got ${input}.`
190
190
  };
191
191
  if (options.min != null && value < options.min) return {
192
192
  success: false,
193
- error: require_message.message`Expected a value greater than or equal to ${require_message.text(options.min.toLocaleString("en"))}, but got ${input}.`
193
+ error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value, options.min) : options.errors.belowMinimum : require_message.message`Expected a value greater than or equal to ${require_message.text(options.min.toLocaleString("en"))}, but got ${input}.`
194
194
  };
195
195
  else if (options.max != null && value > options.max) return {
196
196
  success: false,
197
- error: require_message.message`Expected a value less than or equal to ${require_message.text(options.max.toLocaleString("en"))}, but got ${input}.`
197
+ error: options.errors?.aboveMaximum ? typeof options.errors.aboveMaximum === "function" ? options.errors.aboveMaximum(value, options.max) : options.errors.aboveMaximum : require_message.message`Expected a value less than or equal to ${require_message.text(options.max.toLocaleString("en"))}, but got ${input}.`
198
198
  };
199
199
  return {
200
200
  success: true,
@@ -222,12 +222,12 @@ function url(options = {}) {
222
222
  parse(input) {
223
223
  if (!URL.canParse(input)) return {
224
224
  success: false,
225
- error: require_message.message`Invalid URL: ${input}.`
225
+ error: options.errors?.invalidUrl ? typeof options.errors.invalidUrl === "function" ? options.errors.invalidUrl(input) : options.errors.invalidUrl : require_message.message`Invalid URL: ${input}.`
226
226
  };
227
227
  const url$1 = new URL(input);
228
228
  if (allowedProtocols != null && !allowedProtocols.includes(url$1.protocol)) return {
229
229
  success: false,
230
- error: require_message.message`URL protocol ${url$1.protocol} is not allowed. Allowed protocols: ${allowedProtocols.join(", ")}.`
230
+ error: options.errors?.disallowedProtocol ? typeof options.errors.disallowedProtocol === "function" ? options.errors.disallowedProtocol(url$1.protocol, options.allowedProtocols) : options.errors.disallowedProtocol : require_message.message`URL protocol ${url$1.protocol} is not allowed. Allowed protocols: ${allowedProtocols.join(", ")}.`
231
231
  };
232
232
  return {
233
233
  success: true,
@@ -259,7 +259,7 @@ function locale(options = {}) {
259
259
  } catch (e) {
260
260
  if (e instanceof RangeError) return {
261
261
  success: false,
262
- error: require_message.message`Invalid locale: ${input}.`
262
+ error: options.errors?.invalidLocale ? typeof options.errors.invalidLocale === "function" ? options.errors.invalidLocale(input) : options.errors.invalidLocale : require_message.message`Invalid locale: ${input}.`
263
263
  };
264
264
  throw e;
265
265
  }
@@ -292,23 +292,23 @@ function uuid(options = {}) {
292
292
  parse(input) {
293
293
  if (!uuidRegex.test(input)) return {
294
294
  success: false,
295
- error: require_message.message`Expected a valid UUID in format ${"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}, but got ${input}.`
295
+ error: options.errors?.invalidUuid ? typeof options.errors.invalidUuid === "function" ? options.errors.invalidUuid(input) : options.errors.invalidUuid : require_message.message`Expected a valid UUID in format ${"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}, but got ${input}.`
296
296
  };
297
297
  if (options.allowedVersions != null && options.allowedVersions.length > 0) {
298
298
  const versionChar = input.charAt(14);
299
299
  const version = parseInt(versionChar, 16);
300
- if (!options.allowedVersions.includes(version)) {
301
- let expectedVersions = require_message.message``;
302
- let i = 0;
303
- for (const v of options.allowedVersions) {
304
- expectedVersions = i < 1 ? require_message.message`${expectedVersions}${v.toLocaleString("en")}` : i + 1 >= options.allowedVersions.length ? require_message.message`${expectedVersions}, or ${v.toLocaleString("en")}` : require_message.message`${expectedVersions}, ${v.toLocaleString("en")}`;
305
- i++;
306
- }
307
- return {
308
- success: false,
309
- error: require_message.message`Expected UUID version ${expectedVersions}, but got version ${version.toLocaleString("en")}.`
310
- };
311
- }
300
+ if (!options.allowedVersions.includes(version)) return {
301
+ success: false,
302
+ error: options.errors?.disallowedVersion ? typeof options.errors.disallowedVersion === "function" ? options.errors.disallowedVersion(version, options.allowedVersions) : options.errors.disallowedVersion : (() => {
303
+ let expectedVersions = require_message.message``;
304
+ let i = 0;
305
+ for (const v of options.allowedVersions) {
306
+ expectedVersions = i < 1 ? require_message.message`${expectedVersions}${v.toLocaleString("en")}` : i + 1 >= options.allowedVersions.length ? require_message.message`${expectedVersions}, or ${v.toLocaleString("en")}` : require_message.message`${expectedVersions}, ${v.toLocaleString("en")}`;
307
+ i++;
308
+ }
309
+ return require_message.message`Expected UUID version ${expectedVersions}, but got version ${version.toLocaleString("en")}.`;
310
+ })()
311
+ };
312
312
  }
313
313
  return {
314
314
  success: true,
@@ -70,6 +70,18 @@ interface StringOptions {
70
70
  * Optional regular expression pattern that the string must match.
71
71
  */
72
72
  readonly pattern?: RegExp;
73
+ /**
74
+ * Custom error messages for various string parsing failures.
75
+ * @since 0.5.0
76
+ */
77
+ readonly errors?: {
78
+ /**
79
+ * Custom error message when input doesn't match the pattern.
80
+ * Can be a static message or a function that receives the input and pattern.
81
+ * @since 0.5.0
82
+ */
83
+ patternMismatch?: Message | ((input: string, pattern: RegExp) => Message);
84
+ };
73
85
  }
74
86
  /**
75
87
  * Options for creating a {@link choice} parser.
@@ -90,6 +102,18 @@ interface ChoiceOptions {
90
102
  * @default `false`
91
103
  */
92
104
  readonly caseInsensitive?: boolean;
105
+ /**
106
+ * Custom error messages for choice parsing failures.
107
+ * @since 0.5.0
108
+ */
109
+ readonly errors?: {
110
+ /**
111
+ * Custom error message when input doesn't match any of the valid choices.
112
+ * Can be a static message or a function that receives the input and valid choices.
113
+ * @since 0.5.0
114
+ */
115
+ invalidChoice?: Message | ((input: string, choices: readonly string[]) => Message);
116
+ };
93
117
  }
94
118
  /**
95
119
  * A predicate function that checks if an object is a {@link ValueParser}.
@@ -149,6 +173,30 @@ interface IntegerOptionsNumber {
149
173
  * no maximum is enforced.
150
174
  */
151
175
  readonly max?: number;
176
+ /**
177
+ * Custom error messages for integer parsing failures.
178
+ * @since 0.5.0
179
+ */
180
+ readonly errors?: {
181
+ /**
182
+ * Custom error message when input is not a valid integer.
183
+ * Can be a static message or a function that receives the input.
184
+ * @since 0.5.0
185
+ */
186
+ invalidInteger?: Message | ((input: string) => Message);
187
+ /**
188
+ * Custom error message when integer is below minimum value.
189
+ * Can be a static message or a function that receives the value and minimum.
190
+ * @since 0.5.0
191
+ */
192
+ belowMinimum?: Message | ((value: number, min: number) => Message);
193
+ /**
194
+ * Custom error message when integer is above maximum value.
195
+ * Can be a static message or a function that receives the value and maximum.
196
+ * @since 0.5.0
197
+ */
198
+ aboveMaximum?: Message | ((value: number, max: number) => Message);
199
+ };
152
200
  }
153
201
  /**
154
202
  * Options for creating an integer parser that returns a `bigint`.
@@ -176,6 +224,30 @@ interface IntegerOptionsBigInt {
176
224
  * no maximum is enforced.
177
225
  */
178
226
  readonly max?: bigint;
227
+ /**
228
+ * Custom error messages for bigint integer parsing failures.
229
+ * @since 0.5.0
230
+ */
231
+ readonly errors?: {
232
+ /**
233
+ * Custom error message when input is not a valid integer.
234
+ * Can be a static message or a function that receives the input.
235
+ * @since 0.5.0
236
+ */
237
+ invalidInteger?: Message | ((input: string) => Message);
238
+ /**
239
+ * Custom error message when integer is below minimum value.
240
+ * Can be a static message or a function that receives the value and minimum.
241
+ * @since 0.5.0
242
+ */
243
+ belowMinimum?: Message | ((value: bigint, min: bigint) => Message);
244
+ /**
245
+ * Custom error message when integer is above maximum value.
246
+ * Can be a static message or a function that receives the value and maximum.
247
+ * @since 0.5.0
248
+ */
249
+ aboveMaximum?: Message | ((value: bigint, max: bigint) => Message);
250
+ };
179
251
  }
180
252
  /**
181
253
  * Creates a ValueParser for integers that returns JavaScript numbers.
@@ -226,6 +298,30 @@ interface FloatOptions {
226
298
  * @default `false`
227
299
  */
228
300
  readonly allowInfinity?: boolean;
301
+ /**
302
+ * Custom error messages for float parsing failures.
303
+ * @since 0.5.0
304
+ */
305
+ readonly errors?: {
306
+ /**
307
+ * Custom error message when input is not a valid number.
308
+ * Can be a static message or a function that receives the input.
309
+ * @since 0.5.0
310
+ */
311
+ invalidNumber?: Message | ((input: string) => Message);
312
+ /**
313
+ * Custom error message when number is below minimum value.
314
+ * Can be a static message or a function that receives the value and minimum.
315
+ * @since 0.5.0
316
+ */
317
+ belowMinimum?: Message | ((value: number, min: number) => Message);
318
+ /**
319
+ * Custom error message when number is above maximum value.
320
+ * Can be a static message or a function that receives the value and maximum.
321
+ * @since 0.5.0
322
+ */
323
+ aboveMaximum?: Message | ((value: number, max: number) => Message);
324
+ };
229
325
  }
230
326
  /**
231
327
  * Creates a {@link ValueParser} for floating-point numbers.
@@ -255,6 +351,24 @@ interface UrlOptions {
255
351
  * If not specified, any protocol is allowed.
256
352
  */
257
353
  readonly allowedProtocols?: readonly string[];
354
+ /**
355
+ * Custom error messages for URL parsing failures.
356
+ * @since 0.5.0
357
+ */
358
+ readonly errors?: {
359
+ /**
360
+ * Custom error message when input is not a valid URL.
361
+ * Can be a static message or a function that receives the input.
362
+ * @since 0.5.0
363
+ */
364
+ invalidUrl?: Message | ((input: string) => Message);
365
+ /**
366
+ * Custom error message when URL protocol is not allowed.
367
+ * Can be a static message or a function that receives the protocol and allowed protocols.
368
+ * @since 0.5.0
369
+ */
370
+ disallowedProtocol?: Message | ((protocol: string, allowedProtocols: readonly string[]) => Message);
371
+ };
258
372
  }
259
373
  /**
260
374
  * Creates a {@link ValueParser} for URL values.
@@ -277,6 +391,18 @@ interface LocaleOptions {
277
391
  * @default `"LOCALE"`
278
392
  */
279
393
  readonly metavar?: string;
394
+ /**
395
+ * Custom error messages for locale parsing failures.
396
+ * @since 0.5.0
397
+ */
398
+ readonly errors?: {
399
+ /**
400
+ * Custom error message when input is not a valid locale identifier.
401
+ * Can be a static message or a function that receives the input.
402
+ * @since 0.5.0
403
+ */
404
+ invalidLocale?: Message | ((input: string) => Message);
405
+ };
280
406
  }
281
407
  /**
282
408
  * Creates a {@link ValueParser} for locale values.
@@ -314,6 +440,24 @@ interface UuidOptions {
314
440
  * allowed versions. If not specified, any valid UUID format is accepted.
315
441
  */
316
442
  readonly allowedVersions?: readonly number[];
443
+ /**
444
+ * Custom error messages for UUID parsing failures.
445
+ * @since 0.5.0
446
+ */
447
+ readonly errors?: {
448
+ /**
449
+ * Custom error message when input is not a valid UUID format.
450
+ * Can be a static message or a function that receives the input.
451
+ * @since 0.5.0
452
+ */
453
+ invalidUuid?: Message | ((input: string) => Message);
454
+ /**
455
+ * Custom error message when UUID version is not allowed.
456
+ * Can be a static message or a function that receives the version and allowed versions.
457
+ * @since 0.5.0
458
+ */
459
+ disallowedVersion?: Message | ((version: number, allowedVersions: readonly number[]) => Message);
460
+ };
317
461
  }
318
462
  /**
319
463
  * Creates a {@link ValueParser} for UUID values.
@@ -70,6 +70,18 @@ interface StringOptions {
70
70
  * Optional regular expression pattern that the string must match.
71
71
  */
72
72
  readonly pattern?: RegExp;
73
+ /**
74
+ * Custom error messages for various string parsing failures.
75
+ * @since 0.5.0
76
+ */
77
+ readonly errors?: {
78
+ /**
79
+ * Custom error message when input doesn't match the pattern.
80
+ * Can be a static message or a function that receives the input and pattern.
81
+ * @since 0.5.0
82
+ */
83
+ patternMismatch?: Message | ((input: string, pattern: RegExp) => Message);
84
+ };
73
85
  }
74
86
  /**
75
87
  * Options for creating a {@link choice} parser.
@@ -90,6 +102,18 @@ interface ChoiceOptions {
90
102
  * @default `false`
91
103
  */
92
104
  readonly caseInsensitive?: boolean;
105
+ /**
106
+ * Custom error messages for choice parsing failures.
107
+ * @since 0.5.0
108
+ */
109
+ readonly errors?: {
110
+ /**
111
+ * Custom error message when input doesn't match any of the valid choices.
112
+ * Can be a static message or a function that receives the input and valid choices.
113
+ * @since 0.5.0
114
+ */
115
+ invalidChoice?: Message | ((input: string, choices: readonly string[]) => Message);
116
+ };
93
117
  }
94
118
  /**
95
119
  * A predicate function that checks if an object is a {@link ValueParser}.
@@ -149,6 +173,30 @@ interface IntegerOptionsNumber {
149
173
  * no maximum is enforced.
150
174
  */
151
175
  readonly max?: number;
176
+ /**
177
+ * Custom error messages for integer parsing failures.
178
+ * @since 0.5.0
179
+ */
180
+ readonly errors?: {
181
+ /**
182
+ * Custom error message when input is not a valid integer.
183
+ * Can be a static message or a function that receives the input.
184
+ * @since 0.5.0
185
+ */
186
+ invalidInteger?: Message | ((input: string) => Message);
187
+ /**
188
+ * Custom error message when integer is below minimum value.
189
+ * Can be a static message or a function that receives the value and minimum.
190
+ * @since 0.5.0
191
+ */
192
+ belowMinimum?: Message | ((value: number, min: number) => Message);
193
+ /**
194
+ * Custom error message when integer is above maximum value.
195
+ * Can be a static message or a function that receives the value and maximum.
196
+ * @since 0.5.0
197
+ */
198
+ aboveMaximum?: Message | ((value: number, max: number) => Message);
199
+ };
152
200
  }
153
201
  /**
154
202
  * Options for creating an integer parser that returns a `bigint`.
@@ -176,6 +224,30 @@ interface IntegerOptionsBigInt {
176
224
  * no maximum is enforced.
177
225
  */
178
226
  readonly max?: bigint;
227
+ /**
228
+ * Custom error messages for bigint integer parsing failures.
229
+ * @since 0.5.0
230
+ */
231
+ readonly errors?: {
232
+ /**
233
+ * Custom error message when input is not a valid integer.
234
+ * Can be a static message or a function that receives the input.
235
+ * @since 0.5.0
236
+ */
237
+ invalidInteger?: Message | ((input: string) => Message);
238
+ /**
239
+ * Custom error message when integer is below minimum value.
240
+ * Can be a static message or a function that receives the value and minimum.
241
+ * @since 0.5.0
242
+ */
243
+ belowMinimum?: Message | ((value: bigint, min: bigint) => Message);
244
+ /**
245
+ * Custom error message when integer is above maximum value.
246
+ * Can be a static message or a function that receives the value and maximum.
247
+ * @since 0.5.0
248
+ */
249
+ aboveMaximum?: Message | ((value: bigint, max: bigint) => Message);
250
+ };
179
251
  }
180
252
  /**
181
253
  * Creates a ValueParser for integers that returns JavaScript numbers.
@@ -226,6 +298,30 @@ interface FloatOptions {
226
298
  * @default `false`
227
299
  */
228
300
  readonly allowInfinity?: boolean;
301
+ /**
302
+ * Custom error messages for float parsing failures.
303
+ * @since 0.5.0
304
+ */
305
+ readonly errors?: {
306
+ /**
307
+ * Custom error message when input is not a valid number.
308
+ * Can be a static message or a function that receives the input.
309
+ * @since 0.5.0
310
+ */
311
+ invalidNumber?: Message | ((input: string) => Message);
312
+ /**
313
+ * Custom error message when number is below minimum value.
314
+ * Can be a static message or a function that receives the value and minimum.
315
+ * @since 0.5.0
316
+ */
317
+ belowMinimum?: Message | ((value: number, min: number) => Message);
318
+ /**
319
+ * Custom error message when number is above maximum value.
320
+ * Can be a static message or a function that receives the value and maximum.
321
+ * @since 0.5.0
322
+ */
323
+ aboveMaximum?: Message | ((value: number, max: number) => Message);
324
+ };
229
325
  }
230
326
  /**
231
327
  * Creates a {@link ValueParser} for floating-point numbers.
@@ -255,6 +351,24 @@ interface UrlOptions {
255
351
  * If not specified, any protocol is allowed.
256
352
  */
257
353
  readonly allowedProtocols?: readonly string[];
354
+ /**
355
+ * Custom error messages for URL parsing failures.
356
+ * @since 0.5.0
357
+ */
358
+ readonly errors?: {
359
+ /**
360
+ * Custom error message when input is not a valid URL.
361
+ * Can be a static message or a function that receives the input.
362
+ * @since 0.5.0
363
+ */
364
+ invalidUrl?: Message | ((input: string) => Message);
365
+ /**
366
+ * Custom error message when URL protocol is not allowed.
367
+ * Can be a static message or a function that receives the protocol and allowed protocols.
368
+ * @since 0.5.0
369
+ */
370
+ disallowedProtocol?: Message | ((protocol: string, allowedProtocols: readonly string[]) => Message);
371
+ };
258
372
  }
259
373
  /**
260
374
  * Creates a {@link ValueParser} for URL values.
@@ -277,6 +391,18 @@ interface LocaleOptions {
277
391
  * @default `"LOCALE"`
278
392
  */
279
393
  readonly metavar?: string;
394
+ /**
395
+ * Custom error messages for locale parsing failures.
396
+ * @since 0.5.0
397
+ */
398
+ readonly errors?: {
399
+ /**
400
+ * Custom error message when input is not a valid locale identifier.
401
+ * Can be a static message or a function that receives the input.
402
+ * @since 0.5.0
403
+ */
404
+ invalidLocale?: Message | ((input: string) => Message);
405
+ };
280
406
  }
281
407
  /**
282
408
  * Creates a {@link ValueParser} for locale values.
@@ -314,6 +440,24 @@ interface UuidOptions {
314
440
  * allowed versions. If not specified, any valid UUID format is accepted.
315
441
  */
316
442
  readonly allowedVersions?: readonly number[];
443
+ /**
444
+ * Custom error messages for UUID parsing failures.
445
+ * @since 0.5.0
446
+ */
447
+ readonly errors?: {
448
+ /**
449
+ * Custom error message when input is not a valid UUID format.
450
+ * Can be a static message or a function that receives the input.
451
+ * @since 0.5.0
452
+ */
453
+ invalidUuid?: Message | ((input: string) => Message);
454
+ /**
455
+ * Custom error message when UUID version is not allowed.
456
+ * Can be a static message or a function that receives the version and allowed versions.
457
+ * @since 0.5.0
458
+ */
459
+ disallowedVersion?: Message | ((version: number, allowedVersions: readonly number[]) => Message);
460
+ };
317
461
  }
318
462
  /**
319
463
  * Creates a {@link ValueParser} for UUID values.