Skip to content

Commit 3c1354c

Browse files
committed
fix(isISO6346): fix regex anchoring and character set comma bug
1 parent 55be035 commit 3c1354c

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/lib/isISO6346.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import assertString from './util/assertString';
33
// https://en.wikipedia.org/wiki/ISO_6346
44
// according to ISO6346 standard, checksum digit is mandatory for freight container but recommended
55
// for other container types (J and Z)
6-
const isISO6346Str = /^[A-Z]{3}(U[0-9]{7})|([J,Z][0-9]{6,7})$/;
6+
const isISO6346Str = /^[A-Z]{3}(U[0-9]{7}|[JZ][0-9]{6,7})$/;
77
const isDigit = /^[0-9]$/;
88

99
export function isISO6346(str) {

test/validators.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13544,6 +13544,11 @@ describe('Validators', () => {
1354413544
'ECMJ4657496',
1354513545
'TBJA7176445',
1354613546
'AFFU5962593',
13547+
'abcHLXU2008419',
13548+
'HLXU2008419abc',
13549+
'abcQJRZ123456',
13550+
'QJRZ123456abc',
13551+
'QJR,123456',
1354713552
],
1354813553
});
1354913554
});
@@ -13569,6 +13574,11 @@ describe('Validators', () => {
1356913574
'ECMJ4657496',
1357013575
'TBJA7176445',
1357113576
'AFFU5962593',
13577+
'abcHLXU2008419',
13578+
'HLXU2008419abc',
13579+
'abcQJRZ123456',
13580+
'QJRZ123456abc',
13581+
'QJR,123456',
1357213582
],
1357313583
});
1357413584
});

0 commit comments

Comments
 (0)