Skip to content

Commit

Permalink
fix(identifiers): allow for shorter and longer german crn
Browse files Browse the repository at this point in the history
Some examples of german company registration numbers did not work with old pattern. See 'HRB 42' or 'HRB 209459 B'. Min/max length alligned with worldwide pattern.

Refs: eclipse-tractusx#190
  • Loading branch information
typecastcloud committed Aug 28, 2024
1 parent 2250f34 commit 2c3ee8f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/types/Patterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const VAT_ID = {
}
const COMMERCIAL_REG_NUMBER = {
Worldwide: /^(?!.*\s$)([A-Za-z0-9](\.|\s|-)?){4,21}$/, // generic pattern
DE: /^(?!.*\s$)([A-Za-z0-9](\s|-)?){9}$/,
DE: /^(?!.*\s$)([A-Za-z0-9](\s|-)?){4,21}$/,
FR: /^(?!.*\s$)([A-Za-z0-9]\s?){14,17}$/,
}

Expand Down
24 changes: 13 additions & 11 deletions src/types/testdata/crn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,22 @@ export const CRN_TEST_DATA = {
'987654321',
'000000000',
// Valid records found at https://www.unternehmensregister.de/ureg/ (German Handelsregister)
// 'HRB 209459',
// 'HRB 86891',
// 'HRA 5778',
// 'HRB 112676',
// 'HRB 92821',
// 'VR 9277',
// 'HRB 42', // Südzucker AG
// 'HRA 3679 FL'
'HRB 209459',
'HRB 86891',
'HRA 5778',
'HRB 112676',
'HRB 92821',
'VR 9277',
'HRB 42', // Südzucker AG
'HRA 3679 FL',
'HRB 209459 B',
],
invalid: [
'', // empty
' ', // whitespace
'123456789 ', // trailing whitespace
' 123456789', // leading whitespace
'12345 6789', // invalid character (double whitespace)
// 'HRB 209459 ', // trailing whitespace
// ' HRB 209459', // leading whitespace
// 'HRB 2094590', // invalid character (double whitespace)
],
},
FR: {
Expand All @@ -56,6 +54,7 @@ export const CRN_TEST_DATA = {
' ', // whitespace
'83449681200035 ', // trailing whitespace
' 83449681200035', // leading whitespace
'8344968 1200035', // invalid character (double whitespace)
],
},
MX: {
Expand All @@ -69,6 +68,7 @@ export const CRN_TEST_DATA = {
' ', // whitespace
'ABC20010101AAA ', // trailing space
' ABC20010101AAA', // leading space
'ABC200 10101AAA', // invalid character (double whitespace)
],
},
IN: {
Expand All @@ -82,6 +82,7 @@ export const CRN_TEST_DATA = {
' ', // whitespace
'27AASCS2460H1Z0 ', // trailing space
' 27AASCS2460H1Z0', // leading space
'27AASCS 2460H1Z0', // invalid character (double whitespace)
],
},
Worldwide: {
Expand All @@ -99,6 +100,7 @@ export const CRN_TEST_DATA = {
' ', // whitespace
' DE123456789', // leading space
'DE123456789 ', // trailing space
'DE 123456789', // invalid character (double whitespace)
],
},
}

0 comments on commit 2c3ee8f

Please sign in to comment.