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
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:
+5
-1
@@ -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] };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user