Skip to content

Commit

Permalink
feat: extend legal entity pattern to support all language
Browse files Browse the repository at this point in the history
The legal entity pattern now supports and uses letter and currency unicode categories. This required update of ecma script to version 6.

Refs: eclipse-tractusx/portal#360
  • Loading branch information
typecastcloud committed Aug 20, 2024
1 parent 2250f34 commit 2aeec26
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 26 deletions.
7 changes: 5 additions & 2 deletions src/types/Patterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ export const Patterns = {
STREET:
/^(?!.*\s$)([a-zA-Z0-9À-ÿšŚął]{1,40}( ?[.,'/-] ?| )?){1,10}[a-zA-Z0-9À-ÿšŚął.]$/,
// legalEntityPattern
// \w covers A-Za-z0-9 and _
// \p{L} or \p{Letter} covers all letters in any language (Thai does not work)
// \p{Sc} or \p{Currency_Symbol} covers currency symbols
// \u0E00-\u0E7Fa covers Thai characters
// \d digits
// \s whitespace
// \x22 double quote
legalEntityPattern:
/^(?!.*\s$)([\wÀ-ÿ£$€¥¢@%*+\-/\\,.:;=<>!?&^#'\x22()[\]]\s?){1,160}$/,
/^(?!.*\s$)([\p{L}\u0E00-\u0E7F\d\p{Sc}@%*+_\-/\\,.:;=<>!?&^#'\x22()[\]]\s?){1,160}$/u,
registeredNamePattern:
/^(?!.*\s$)[a-zA-ZÀ-ÿŚął\d][a-zA-ZÀ-ÿŚął\d\s!#'$@&%()*+,\-_./:;=<>?[\]\\^]{2,60}$/,
regionPattern: /^(?!.*\s$)([a-zA-Z0-9À-ÿŚął,"()'-]\s?)*$/,
Expand Down
49 changes: 28 additions & 21 deletions src/types/testdata/legalentity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ export const LEGAL_ENTITY_DATA = {
'+SEN Inc.', // leading special character
'La Poste S.A.',
'JPMORGAN ASIA-PACIFIC ADVANTAGE HYBRID FUND (QDII)',
'Currency £$€¥¢',
'摩根亚太优势混合型证券投资基金 (QDII)',
'Adis Tachov, zpracování plastů s.r.o.',
'BURY SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ',
'GAMMO Europe Korlátolt Felelősségű Társaság',
'Currency £$€¥¢₫฿',
'Brackets []()',
'Punctuation !?,.;:',
'Double "Quote" Company S.A.', // special character "" in name
Expand All @@ -51,26 +55,29 @@ export const LEGAL_ENTITY_DATA = {
'Icelandic: ÆÐÞ',
'Dutch: ÏËÏ',
// -- not supported by the pattern
// 'ACE 9 SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ',
// '摩根亚太优势混合型证券投资基金 (QDII)',
// '삼성', // Samsung
// '三', // Samsung
// 'Czech: ČĎŇŘŠŤŽ',
// 'Estonian: ÄÖÜŠŽ',
// 'Slovak: ĽĹŔŠŤŽ',
// 'Polish: ĄĆĘŁŃÓŚŹŻ',
// 'Hungarian: ÁÉÍÓÖŐÚÜŰ',
// 'Romanian: ÂÎŞŢ',
// 'Bulgarian: ЙЪЬ',
// 'Greek: ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ',
// 'Turkish: ÇĞİıÖŞÜ',
// 'Arabic: ابتثجحخدذرزسشصضطظعغفقكلمنهوي',
// 'Hebrew: שלום עולם',
// 'Hindi: अआइईउऊऋएऐओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलवशषस',
// 'Japanese: あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをん',
// 'Chinese: 你好 世界',
// 'Korean: 안녕하세요 세계',
// 'Thai: สวัสดีชาวโลก', // Thai does not seem to work even with /p{L}
'ACE 9 SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ',
'摩根亚太优势混合型证券投资基金 (QDII)',
'삼성', // Samsung
'三', // Samsung
'Czech: ČĎŇŘŠŤŽ',
'Estonian: ÄÖÜŠŽ',
'Slovak: ĽĹŔŠŤŽ',
'Polish: ĄĆĘŁŃÓŚŹŻ',
'Hungarian: ÁÉÍÓÖŐÚÜŰ',
'Romanian: ÂÎŞŢ',
'Bulgarian: ЙЪЬ',
'Greek: ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ',
'Turkish: ÇĞİıÖŞÜ',
'Arabic: ابتثجحخدذرزسشصضطظعغفقكلمنهوي',
'Hebrew: שלום עולם',
'Hindi: अआइईउऊऋएऐओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलवशषस',
'Tamil: அஆஇஈஉஊஎஏஐஒஓஔகஙசஞடணதநனபமயரலவழளஷஸஹ',
'Japanese: あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをん',
'Chinese: 你好 世界',
'Korean: 안녕하세요 세계',
'Thai: สวัสดีชาวโลก', // Thai does not seem to work even with /p{L} and required additional range
'Vietnamese: ăâắáấàằầảẳẩãẵẫạặậđêéếèềẻểẽễẹệíìỉĩịôơóốớòồờỏổởõỗỡọộợưúứùừủửũữụựýỳỷỹỵ',
'Singapore: 你好 世界',
],
invalid: [
' Bayerische Motoren Werke Aktiengesellschaft', // leading space
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"compilerOptions": {
"target": "ES5",
"target": "ES6",
"useDefineForClassFields": true,
"lib": ["ES5", "DOM", "DOM.Iterable"],
"lib": ["ES6", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"esModuleInterop": true,
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json.orig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "es6",
"lib": [
"dom",
"dom.iterable",
Expand Down

0 comments on commit 2aeec26

Please sign in to comment.