-
Notifications
You must be signed in to change notification settings - Fork 139
Description
According to the Visa spec TLV-format fields can contain multiple occurrences of same datasets and tags.
For instance, messages containing itemized statements may contain multiples of same
dataset IDs, each possibly having same TLV elements for line items of statements or
receipts.
Example from composite-fields.md
field125Spec := &field.Spec{
Length: 255,
Description: "Extended Transaction Data",
Pref: prefix.Binary.L,
Tag: &field.TagSpec{
Length: 1, // Data Set ID length in bytes
Enc: encoding.ASCIIHexToBytes, // Data Set ID below is ASCII hex and will be converted to bytes (1 byte)
Sort: sort.StringsByHex,
// Handle unknown Data Set IDs
SkipUnknownTLVTags: true,
PrefUnknownTLV: prefix.Binary.LL, // Data Set length format
},
Subfields: map[string]field.Field{
"56": field.NewComposite(&field.Spec{ // Data Set ID <-------- This Dataset can occur n times
Length: 1535,
Description: "Merchant Information Data",
Pref: prefix.Binary.LL, // Length of the entire Data Set value
Tag: &field.TagSpec{
Enc: encoding.BerTLVTag,
Sort: sort.StringsByHex,
SkipUnknownTLVTags: true,
},
Subfields: map[string]field.Field{
"01": field.NewString(&field.Spec{ <-------- This Tag can occur n times
Length: 11,
Description: "Merchant Identifier",
Enc: encoding.EBCDIC,
Pref: prefix.BerTLV,
}),
},
}),
}
If multiple occurrences of Dataset IDs or tags, are in the message, it will be overwritten.
Looking at the bertlv library, it supports multiple tags within a dataset, which is nice and we could use that to parse the dataset. But then we also need to be able to handle multiple datasets with the same ID.
My question is if there is any planned support for this? I'm unsure if this is a Visa specific requirement, or if the library might be silently overriding multiple occurrences in the case of someone defining the whole spec like the example.