@optique/core 1.0.0-dev.1197 → 1.0.0-dev.1202
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/facade.cjs +3 -3
- package/dist/facade.js +3 -3
- package/dist/program.cjs +1 -1
- package/dist/program.d.cts +2 -2
- package/dist/program.d.ts +2 -2
- package/dist/program.js +1 -1
- package/dist/valueparser.cjs +35 -4
- package/dist/valueparser.d.cts +38 -3
- package/dist/valueparser.d.ts +38 -3
- package/dist/valueparser.js +35 -4
- package/package.json +1 -1
package/dist/facade.cjs
CHANGED
|
@@ -670,7 +670,7 @@ function handleCompletion(completionArgs, programName, parser, completionParser,
|
|
|
670
670
|
if (!shellName) {
|
|
671
671
|
stderr("Error: Missing shell name for completion.\n");
|
|
672
672
|
if (completionParser) {
|
|
673
|
-
const displayName = completionCommandDisplayName ?? "completion";
|
|
673
|
+
const displayName = isOptionMode ? completionOptionDisplayName ?? "--completion" : completionCommandDisplayName ?? "completion";
|
|
674
674
|
const doc = require_parser.getDocPage(completionParser, [displayName]);
|
|
675
675
|
if (doc) stderr(require_doc.formatDocPage(programName, doc, {
|
|
676
676
|
colors,
|
|
@@ -869,13 +869,13 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
869
869
|
if (equalsMatch) {
|
|
870
870
|
const shell = arg.slice(equalsMatch.length + 1);
|
|
871
871
|
const completionArgs = args.slice(i + 1);
|
|
872
|
-
return handleCompletion([shell, ...completionArgs], programName, parser, completionParsers.
|
|
872
|
+
return handleCompletion([shell, ...completionArgs], programName, parser, completionParsers.completionOption, stdout, stderr, onCompletionResult, onErrorResult, availableShells, colors, maxWidth, completionCommandNames[0], completionOptionNames[0], true, sectionOrder);
|
|
873
873
|
}
|
|
874
874
|
const exactMatch = completionOptionNames.includes(arg);
|
|
875
875
|
if (exactMatch) {
|
|
876
876
|
const shell = i + 1 < args.length ? args[i + 1] : "";
|
|
877
877
|
const completionArgs = i + 1 < args.length ? args.slice(i + 2) : [];
|
|
878
|
-
return handleCompletion([shell, ...completionArgs], programName, parser, completionParsers.
|
|
878
|
+
return handleCompletion([shell, ...completionArgs], programName, parser, completionParsers.completionOption, stdout, stderr, onCompletionResult, onErrorResult, availableShells, colors, maxWidth, completionCommandNames[0], completionOptionNames[0], true, sectionOrder);
|
|
879
879
|
}
|
|
880
880
|
}
|
|
881
881
|
}
|
package/dist/facade.js
CHANGED
|
@@ -670,7 +670,7 @@ function handleCompletion(completionArgs, programName, parser, completionParser,
|
|
|
670
670
|
if (!shellName) {
|
|
671
671
|
stderr("Error: Missing shell name for completion.\n");
|
|
672
672
|
if (completionParser) {
|
|
673
|
-
const displayName = completionCommandDisplayName ?? "completion";
|
|
673
|
+
const displayName = isOptionMode ? completionOptionDisplayName ?? "--completion" : completionCommandDisplayName ?? "completion";
|
|
674
674
|
const doc = getDocPage(completionParser, [displayName]);
|
|
675
675
|
if (doc) stderr(formatDocPage(programName, doc, {
|
|
676
676
|
colors,
|
|
@@ -869,13 +869,13 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
869
869
|
if (equalsMatch) {
|
|
870
870
|
const shell = arg.slice(equalsMatch.length + 1);
|
|
871
871
|
const completionArgs = args.slice(i + 1);
|
|
872
|
-
return handleCompletion([shell, ...completionArgs], programName, parser, completionParsers.
|
|
872
|
+
return handleCompletion([shell, ...completionArgs], programName, parser, completionParsers.completionOption, stdout, stderr, onCompletionResult, onErrorResult, availableShells, colors, maxWidth, completionCommandNames[0], completionOptionNames[0], true, sectionOrder);
|
|
873
873
|
}
|
|
874
874
|
const exactMatch = completionOptionNames.includes(arg);
|
|
875
875
|
if (exactMatch) {
|
|
876
876
|
const shell = i + 1 < args.length ? args[i + 1] : "";
|
|
877
877
|
const completionArgs = i + 1 < args.length ? args.slice(i + 2) : [];
|
|
878
|
-
return handleCompletion([shell, ...completionArgs], programName, parser, completionParsers.
|
|
878
|
+
return handleCompletion([shell, ...completionArgs], programName, parser, completionParsers.completionOption, stdout, stderr, onCompletionResult, onErrorResult, availableShells, colors, maxWidth, completionCommandNames[0], completionOptionNames[0], true, sectionOrder);
|
|
879
879
|
}
|
|
880
880
|
}
|
|
881
881
|
}
|
package/dist/program.cjs
CHANGED
package/dist/program.d.cts
CHANGED
|
@@ -71,7 +71,7 @@ interface ProgramMetadata {
|
|
|
71
71
|
* };
|
|
72
72
|
* ```
|
|
73
73
|
*
|
|
74
|
-
* @since 0.
|
|
74
|
+
* @since 1.0.0
|
|
75
75
|
*/
|
|
76
76
|
interface Program<M extends Mode, T> {
|
|
77
77
|
/**
|
|
@@ -117,7 +117,7 @@ interface Program<M extends Mode, T> {
|
|
|
117
117
|
* // Program<"sync", { readonly name: string }>
|
|
118
118
|
* ```
|
|
119
119
|
*
|
|
120
|
-
* @since 0.
|
|
120
|
+
* @since 1.0.0
|
|
121
121
|
*/
|
|
122
122
|
declare function defineProgram<M extends Mode, T>(program: Program<M, T>): Program<M, T>;
|
|
123
123
|
//#endregion
|
package/dist/program.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ interface ProgramMetadata {
|
|
|
71
71
|
* };
|
|
72
72
|
* ```
|
|
73
73
|
*
|
|
74
|
-
* @since 0.
|
|
74
|
+
* @since 1.0.0
|
|
75
75
|
*/
|
|
76
76
|
interface Program<M extends Mode, T> {
|
|
77
77
|
/**
|
|
@@ -117,7 +117,7 @@ interface Program<M extends Mode, T> {
|
|
|
117
117
|
* // Program<"sync", { readonly name: string }>
|
|
118
118
|
* ```
|
|
119
119
|
*
|
|
120
|
-
* @since 0.
|
|
120
|
+
* @since 1.0.0
|
|
121
121
|
*/
|
|
122
122
|
declare function defineProgram<M extends Mode, T>(program: Program<M, T>): Program<M, T>;
|
|
123
123
|
//#endregion
|
package/dist/program.js
CHANGED
package/dist/valueparser.cjs
CHANGED
|
@@ -797,9 +797,14 @@ function locale(options = {}) {
|
|
|
797
797
|
*
|
|
798
798
|
* This parser validates that the input is a well-formed UUID string in the
|
|
799
799
|
* standard format: `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` where each `x`
|
|
800
|
-
* is a hexadecimal digit.
|
|
801
|
-
* UUID versions.
|
|
800
|
+
* is a hexadecimal digit.
|
|
802
801
|
*
|
|
802
|
+
* By default, the parser enforces strict [RFC 9562] validation: it requires
|
|
803
|
+
* a standardized version digit (1 through 8) and the RFC 9562 variant bits
|
|
804
|
+
* (`10xx`). The nil and max UUIDs are accepted as special standard values.
|
|
805
|
+
* Set `strict: false` to disable version and variant validation.
|
|
806
|
+
*
|
|
807
|
+
* [RFC 9562]: https://www.rfc-editor.org/rfc/rfc9562
|
|
803
808
|
* @param options Configuration options for the UUID parser.
|
|
804
809
|
* @returns A {@link ValueParser} that converts string input to {@link Uuid}
|
|
805
810
|
* strings.
|
|
@@ -808,9 +813,11 @@ function uuid(options = {}) {
|
|
|
808
813
|
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
809
814
|
const metavar = options.metavar ?? "UUID";
|
|
810
815
|
require_nonempty.ensureNonEmptyString(metavar);
|
|
816
|
+
const strict = options.strict !== false;
|
|
811
817
|
const allowedVersions = options.allowedVersions != null ? Object.freeze([...options.allowedVersions]) : null;
|
|
812
818
|
const invalidUuid = options.errors?.invalidUuid;
|
|
813
819
|
const disallowedVersion = options.errors?.disallowedVersion;
|
|
820
|
+
const invalidVariant = options.errors?.invalidVariant;
|
|
814
821
|
return {
|
|
815
822
|
$mode: "sync",
|
|
816
823
|
metavar,
|
|
@@ -819,9 +826,14 @@ function uuid(options = {}) {
|
|
|
819
826
|
success: false,
|
|
820
827
|
error: invalidUuid ? typeof invalidUuid === "function" ? invalidUuid(input) : invalidUuid : require_message.message`Expected a valid UUID in format ${"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}, but got ${input}.`
|
|
821
828
|
};
|
|
829
|
+
const lower = input.toLowerCase();
|
|
830
|
+
if (lower === "00000000-0000-0000-0000-000000000000" || lower === "ffffffff-ffff-ffff-ffff-ffffffffffff") return {
|
|
831
|
+
success: true,
|
|
832
|
+
value: input
|
|
833
|
+
};
|
|
834
|
+
const versionChar = input.charAt(14);
|
|
835
|
+
const version = parseInt(versionChar, 16);
|
|
822
836
|
if (allowedVersions != null && allowedVersions.length > 0) {
|
|
823
|
-
const versionChar = input.charAt(14);
|
|
824
|
-
const version = parseInt(versionChar, 16);
|
|
825
837
|
if (!allowedVersions.includes(version)) return {
|
|
826
838
|
success: false,
|
|
827
839
|
error: disallowedVersion ? typeof disallowedVersion === "function" ? disallowedVersion(version, allowedVersions) : disallowedVersion : (() => {
|
|
@@ -834,6 +846,25 @@ function uuid(options = {}) {
|
|
|
834
846
|
return require_message.message`Expected UUID version ${expectedVersions}, but got version ${version.toLocaleString("en")}.`;
|
|
835
847
|
})()
|
|
836
848
|
};
|
|
849
|
+
} else if (strict && (version < 1 || version > 8)) return {
|
|
850
|
+
success: false,
|
|
851
|
+
error: disallowedVersion ? typeof disallowedVersion === "function" ? disallowedVersion(version, [
|
|
852
|
+
1,
|
|
853
|
+
2,
|
|
854
|
+
3,
|
|
855
|
+
4,
|
|
856
|
+
5,
|
|
857
|
+
6,
|
|
858
|
+
7,
|
|
859
|
+
8
|
|
860
|
+
]) : disallowedVersion : require_message.message`Expected UUID version 1 through 8, but got version ${version.toLocaleString("en")}.`
|
|
861
|
+
};
|
|
862
|
+
if (strict) {
|
|
863
|
+
const variantChar = input.charAt(19).toLowerCase();
|
|
864
|
+
if (variantChar !== "8" && variantChar !== "9" && variantChar !== "a" && variantChar !== "b") return {
|
|
865
|
+
success: false,
|
|
866
|
+
error: invalidVariant ? typeof invalidVariant === "function" ? invalidVariant(input) : invalidVariant : require_message.message`Expected RFC 9562 variant (8, 9, a, or b at position 20), but got ${variantChar} in ${input}.`
|
|
867
|
+
};
|
|
837
868
|
}
|
|
838
869
|
return {
|
|
839
870
|
success: true,
|
package/dist/valueparser.d.cts
CHANGED
|
@@ -563,9 +563,33 @@ interface UuidOptions {
|
|
|
563
563
|
/**
|
|
564
564
|
* List of allowed UUID versions (e.g., `[4, 5]` for UUIDs version 4 and 5).
|
|
565
565
|
* If specified, the parser will validate that the UUID matches one of the
|
|
566
|
-
* allowed versions.
|
|
566
|
+
* allowed versions. If not specified, the accepted versions depend on
|
|
567
|
+
* the {@link strict} option.
|
|
567
568
|
*/
|
|
568
569
|
readonly allowedVersions?: readonly number[];
|
|
570
|
+
/**
|
|
571
|
+
* Whether to enforce strict [RFC 9562] validation. When `true` (the
|
|
572
|
+
* default), the parser validates that the version digit is one of the
|
|
573
|
+
* currently standardized versions (1 through 8) and that the variant bits
|
|
574
|
+
* follow the RFC 9562 layout (`10xx`, i.e., hex digits `8`, `9`, `a`,
|
|
575
|
+
* or `b` at position 20 of the UUID string).
|
|
576
|
+
*
|
|
577
|
+
* The nil UUID (`00000000-0000-0000-0000-000000000000`) and max UUID
|
|
578
|
+
* (`ffffffff-ffff-ffff-ffff-ffffffffffff`) are accepted as special
|
|
579
|
+
* standard values regardless of this setting.
|
|
580
|
+
*
|
|
581
|
+
* When `false`, the parser only validates the UUID format without
|
|
582
|
+
* checking version or variant fields.
|
|
583
|
+
*
|
|
584
|
+
* When {@link allowedVersions} is provided, it takes precedence over the
|
|
585
|
+
* strict version check, but variant bit validation still applies if
|
|
586
|
+
* `strict` is `true`.
|
|
587
|
+
*
|
|
588
|
+
* [RFC 9562]: https://www.rfc-editor.org/rfc/rfc9562
|
|
589
|
+
* @default true
|
|
590
|
+
* @since 1.0.0
|
|
591
|
+
*/
|
|
592
|
+
readonly strict?: boolean;
|
|
569
593
|
/**
|
|
570
594
|
* Custom error messages for UUID parsing failures.
|
|
571
595
|
* @since 0.5.0
|
|
@@ -583,6 +607,12 @@ interface UuidOptions {
|
|
|
583
607
|
* @since 0.5.0
|
|
584
608
|
*/
|
|
585
609
|
disallowedVersion?: Message | ((version: number, allowedVersions: readonly number[]) => Message);
|
|
610
|
+
/**
|
|
611
|
+
* Custom error message when UUID variant bits are not RFC 9562 compliant.
|
|
612
|
+
* Can be a static message or a function that receives the input.
|
|
613
|
+
* @since 1.0.0
|
|
614
|
+
*/
|
|
615
|
+
invalidVariant?: Message | ((input: string) => Message);
|
|
586
616
|
};
|
|
587
617
|
}
|
|
588
618
|
/**
|
|
@@ -590,9 +620,14 @@ interface UuidOptions {
|
|
|
590
620
|
*
|
|
591
621
|
* This parser validates that the input is a well-formed UUID string in the
|
|
592
622
|
* standard format: `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` where each `x`
|
|
593
|
-
* is a hexadecimal digit.
|
|
594
|
-
*
|
|
623
|
+
* is a hexadecimal digit.
|
|
624
|
+
*
|
|
625
|
+
* By default, the parser enforces strict [RFC 9562] validation: it requires
|
|
626
|
+
* a standardized version digit (1 through 8) and the RFC 9562 variant bits
|
|
627
|
+
* (`10xx`). The nil and max UUIDs are accepted as special standard values.
|
|
628
|
+
* Set `strict: false` to disable version and variant validation.
|
|
595
629
|
*
|
|
630
|
+
* [RFC 9562]: https://www.rfc-editor.org/rfc/rfc9562
|
|
596
631
|
* @param options Configuration options for the UUID parser.
|
|
597
632
|
* @returns A {@link ValueParser} that converts string input to {@link Uuid}
|
|
598
633
|
* strings.
|
package/dist/valueparser.d.ts
CHANGED
|
@@ -563,9 +563,33 @@ interface UuidOptions {
|
|
|
563
563
|
/**
|
|
564
564
|
* List of allowed UUID versions (e.g., `[4, 5]` for UUIDs version 4 and 5).
|
|
565
565
|
* If specified, the parser will validate that the UUID matches one of the
|
|
566
|
-
* allowed versions.
|
|
566
|
+
* allowed versions. If not specified, the accepted versions depend on
|
|
567
|
+
* the {@link strict} option.
|
|
567
568
|
*/
|
|
568
569
|
readonly allowedVersions?: readonly number[];
|
|
570
|
+
/**
|
|
571
|
+
* Whether to enforce strict [RFC 9562] validation. When `true` (the
|
|
572
|
+
* default), the parser validates that the version digit is one of the
|
|
573
|
+
* currently standardized versions (1 through 8) and that the variant bits
|
|
574
|
+
* follow the RFC 9562 layout (`10xx`, i.e., hex digits `8`, `9`, `a`,
|
|
575
|
+
* or `b` at position 20 of the UUID string).
|
|
576
|
+
*
|
|
577
|
+
* The nil UUID (`00000000-0000-0000-0000-000000000000`) and max UUID
|
|
578
|
+
* (`ffffffff-ffff-ffff-ffff-ffffffffffff`) are accepted as special
|
|
579
|
+
* standard values regardless of this setting.
|
|
580
|
+
*
|
|
581
|
+
* When `false`, the parser only validates the UUID format without
|
|
582
|
+
* checking version or variant fields.
|
|
583
|
+
*
|
|
584
|
+
* When {@link allowedVersions} is provided, it takes precedence over the
|
|
585
|
+
* strict version check, but variant bit validation still applies if
|
|
586
|
+
* `strict` is `true`.
|
|
587
|
+
*
|
|
588
|
+
* [RFC 9562]: https://www.rfc-editor.org/rfc/rfc9562
|
|
589
|
+
* @default true
|
|
590
|
+
* @since 1.0.0
|
|
591
|
+
*/
|
|
592
|
+
readonly strict?: boolean;
|
|
569
593
|
/**
|
|
570
594
|
* Custom error messages for UUID parsing failures.
|
|
571
595
|
* @since 0.5.0
|
|
@@ -583,6 +607,12 @@ interface UuidOptions {
|
|
|
583
607
|
* @since 0.5.0
|
|
584
608
|
*/
|
|
585
609
|
disallowedVersion?: Message | ((version: number, allowedVersions: readonly number[]) => Message);
|
|
610
|
+
/**
|
|
611
|
+
* Custom error message when UUID variant bits are not RFC 9562 compliant.
|
|
612
|
+
* Can be a static message or a function that receives the input.
|
|
613
|
+
* @since 1.0.0
|
|
614
|
+
*/
|
|
615
|
+
invalidVariant?: Message | ((input: string) => Message);
|
|
586
616
|
};
|
|
587
617
|
}
|
|
588
618
|
/**
|
|
@@ -590,9 +620,14 @@ interface UuidOptions {
|
|
|
590
620
|
*
|
|
591
621
|
* This parser validates that the input is a well-formed UUID string in the
|
|
592
622
|
* standard format: `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` where each `x`
|
|
593
|
-
* is a hexadecimal digit.
|
|
594
|
-
*
|
|
623
|
+
* is a hexadecimal digit.
|
|
624
|
+
*
|
|
625
|
+
* By default, the parser enforces strict [RFC 9562] validation: it requires
|
|
626
|
+
* a standardized version digit (1 through 8) and the RFC 9562 variant bits
|
|
627
|
+
* (`10xx`). The nil and max UUIDs are accepted as special standard values.
|
|
628
|
+
* Set `strict: false` to disable version and variant validation.
|
|
595
629
|
*
|
|
630
|
+
* [RFC 9562]: https://www.rfc-editor.org/rfc/rfc9562
|
|
596
631
|
* @param options Configuration options for the UUID parser.
|
|
597
632
|
* @returns A {@link ValueParser} that converts string input to {@link Uuid}
|
|
598
633
|
* strings.
|
package/dist/valueparser.js
CHANGED
|
@@ -797,9 +797,14 @@ function locale(options = {}) {
|
|
|
797
797
|
*
|
|
798
798
|
* This parser validates that the input is a well-formed UUID string in the
|
|
799
799
|
* standard format: `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` where each `x`
|
|
800
|
-
* is a hexadecimal digit.
|
|
801
|
-
* UUID versions.
|
|
800
|
+
* is a hexadecimal digit.
|
|
802
801
|
*
|
|
802
|
+
* By default, the parser enforces strict [RFC 9562] validation: it requires
|
|
803
|
+
* a standardized version digit (1 through 8) and the RFC 9562 variant bits
|
|
804
|
+
* (`10xx`). The nil and max UUIDs are accepted as special standard values.
|
|
805
|
+
* Set `strict: false` to disable version and variant validation.
|
|
806
|
+
*
|
|
807
|
+
* [RFC 9562]: https://www.rfc-editor.org/rfc/rfc9562
|
|
803
808
|
* @param options Configuration options for the UUID parser.
|
|
804
809
|
* @returns A {@link ValueParser} that converts string input to {@link Uuid}
|
|
805
810
|
* strings.
|
|
@@ -808,9 +813,11 @@ function uuid(options = {}) {
|
|
|
808
813
|
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
809
814
|
const metavar = options.metavar ?? "UUID";
|
|
810
815
|
ensureNonEmptyString(metavar);
|
|
816
|
+
const strict = options.strict !== false;
|
|
811
817
|
const allowedVersions = options.allowedVersions != null ? Object.freeze([...options.allowedVersions]) : null;
|
|
812
818
|
const invalidUuid = options.errors?.invalidUuid;
|
|
813
819
|
const disallowedVersion = options.errors?.disallowedVersion;
|
|
820
|
+
const invalidVariant = options.errors?.invalidVariant;
|
|
814
821
|
return {
|
|
815
822
|
$mode: "sync",
|
|
816
823
|
metavar,
|
|
@@ -819,9 +826,14 @@ function uuid(options = {}) {
|
|
|
819
826
|
success: false,
|
|
820
827
|
error: invalidUuid ? typeof invalidUuid === "function" ? invalidUuid(input) : invalidUuid : message`Expected a valid UUID in format ${"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}, but got ${input}.`
|
|
821
828
|
};
|
|
829
|
+
const lower = input.toLowerCase();
|
|
830
|
+
if (lower === "00000000-0000-0000-0000-000000000000" || lower === "ffffffff-ffff-ffff-ffff-ffffffffffff") return {
|
|
831
|
+
success: true,
|
|
832
|
+
value: input
|
|
833
|
+
};
|
|
834
|
+
const versionChar = input.charAt(14);
|
|
835
|
+
const version = parseInt(versionChar, 16);
|
|
822
836
|
if (allowedVersions != null && allowedVersions.length > 0) {
|
|
823
|
-
const versionChar = input.charAt(14);
|
|
824
|
-
const version = parseInt(versionChar, 16);
|
|
825
837
|
if (!allowedVersions.includes(version)) return {
|
|
826
838
|
success: false,
|
|
827
839
|
error: disallowedVersion ? typeof disallowedVersion === "function" ? disallowedVersion(version, allowedVersions) : disallowedVersion : (() => {
|
|
@@ -834,6 +846,25 @@ function uuid(options = {}) {
|
|
|
834
846
|
return message`Expected UUID version ${expectedVersions}, but got version ${version.toLocaleString("en")}.`;
|
|
835
847
|
})()
|
|
836
848
|
};
|
|
849
|
+
} else if (strict && (version < 1 || version > 8)) return {
|
|
850
|
+
success: false,
|
|
851
|
+
error: disallowedVersion ? typeof disallowedVersion === "function" ? disallowedVersion(version, [
|
|
852
|
+
1,
|
|
853
|
+
2,
|
|
854
|
+
3,
|
|
855
|
+
4,
|
|
856
|
+
5,
|
|
857
|
+
6,
|
|
858
|
+
7,
|
|
859
|
+
8
|
|
860
|
+
]) : disallowedVersion : message`Expected UUID version 1 through 8, but got version ${version.toLocaleString("en")}.`
|
|
861
|
+
};
|
|
862
|
+
if (strict) {
|
|
863
|
+
const variantChar = input.charAt(19).toLowerCase();
|
|
864
|
+
if (variantChar !== "8" && variantChar !== "9" && variantChar !== "a" && variantChar !== "b") return {
|
|
865
|
+
success: false,
|
|
866
|
+
error: invalidVariant ? typeof invalidVariant === "function" ? invalidVariant(input) : invalidVariant : message`Expected RFC 9562 variant (8, 9, a, or b at position 20), but got ${variantChar} in ${input}.`
|
|
867
|
+
};
|
|
837
868
|
}
|
|
838
869
|
return {
|
|
839
870
|
success: true,
|