Refuse an empty list for a repeatable TLV
Mirror / push (push) Successful in 6s
Test / lint (pull_request) Successful in 19s
Test / test (18) (pull_request) Successful in 30s
Test / test (20) (pull_request) Successful in 28s
Test / test (22) (pull_request) Successful in 30s
Test / test (24) (pull_request) Successful in 28s
Test / test (26) (pull_request) Successful in 30s

This commit is contained in:
2026-09-24 00:42:03 +02:00
parent 224acca7d0
commit 9c83dd1d99
3 changed files with 10 additions and 3 deletions
+5 -1
View File
@@ -135,7 +135,11 @@ export function tagIdOf(name: string, input: TlvInput): Result<{ tagId: number }
function copiesOf(name: string, definition: TlvDefinition | undefined, value: TlvValue): Result<{ copies: TlvScalar[] }> {
const multiple = definition?.multiple === true;
if (Array.isArray(value) && multiple) return { copies: value };
if (Array.isArray(value) && multiple) {
return value.length > 0
? { copies: value }
: { err: new Error(`TLV "${name}": give at least one value, or leave the tag out`) };
}
if (!Array.isArray(value) && !multiple) return { copies: [value] };