File tree 2 files changed +51
-1
lines changed 2 files changed +51
-1
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ export function isISO6346(str) {
27
27
} else sum += str [ i ] * ( 2 ** i ) ;
28
28
}
29
29
30
- const checkSumDigit = sum % 11 ;
30
+ let checkSumDigit = sum % 11 ;
31
+ if ( checkSumDigit === 10 ) checkSumDigit = 0 ;
31
32
return Number ( str [ str . length - 1 ] ) === checkSumDigit ;
32
33
}
33
34
Original file line number Diff line number Diff line change @@ -13066,6 +13066,55 @@ describe('Validators', () => {
13066
13066
} ) ;
13067
13067
} ) ;
13068
13068
13069
+ it ( 'should validate ISO6346 shipping container IDs with checksum digit 10 represented as 0' , ( ) => {
13070
+ test ( {
13071
+ validator : 'isISO6346' ,
13072
+ valid : [
13073
+ 'APZU3789870' ,
13074
+ 'TEMU1002030' ,
13075
+ 'DFSU1704420' ,
13076
+ 'CMAU2221480' ,
13077
+ 'SEGU5060260' ,
13078
+ 'FCIU8939320' ,
13079
+ 'TRHU3495670' ,
13080
+ 'MEDU3871410' ,
13081
+ 'CMAU2184010' ,
13082
+ 'TCLU2265970' ,
13083
+ ] ,
13084
+ invalid : [
13085
+ 'APZU3789871' , // Incorrect check digit
13086
+ 'TEMU1002031' ,
13087
+ 'DFSU1704421' ,
13088
+ 'CMAU2221481' ,
13089
+ 'SEGU5060261' ,
13090
+ ] ,
13091
+ } ) ;
13092
+ } ) ;
13093
+ it ( 'should validate ISO6346 shipping container IDs with checksum digit 10 represented as 0' , ( ) => {
13094
+ test ( {
13095
+ validator : 'isFreightContainerID' ,
13096
+ valid : [
13097
+ 'APZU3789870' ,
13098
+ 'TEMU1002030' ,
13099
+ 'DFSU1704420' ,
13100
+ 'CMAU2221480' ,
13101
+ 'SEGU5060260' ,
13102
+ 'FCIU8939320' ,
13103
+ 'TRHU3495670' ,
13104
+ 'MEDU3871410' ,
13105
+ 'CMAU2184010' ,
13106
+ 'TCLU2265970' ,
13107
+ ] ,
13108
+ invalid : [
13109
+ 'APZU3789871' , // Incorrect check digit
13110
+ 'TEMU1002031' ,
13111
+ 'DFSU1704421' ,
13112
+ 'CMAU2221481' ,
13113
+ 'SEGU5060261' ,
13114
+ ] ,
13115
+ } ) ;
13116
+ } ) ;
13117
+
13069
13118
// EU-UK valid numbers sourced from https://ec.europa.eu/taxation_customs/tin/specs/FS-TIN%20Algorithms-Public.docx or constructed by @tplessas.
13070
13119
it ( 'should validate taxID' , ( ) => {
13071
13120
test ( {
You can’t perform that action at this time.
0 commit comments