From 5765e4d34008f8d04d37c23aa7f5923d50fcaa3d Mon Sep 17 00:00:00 2001
From: Karsten Thiems <150006841+typecastcloud@users.noreply.github.com>
Date: Mon, 14 Oct 2024 17:15:34 +0200
Subject: [PATCH] feat(validation): update Company validation expression
(#1043)
The Company validation expression in the ValidationExpressions class has been updated to support a wider range of characters, including special characters and non-Latin alphabets. This change ensures that the validation accurately captures company names from different languages and regions.
Fixes: eclipse-tractusx/portal#360
Refs: eclipse-tractusx/portal-frontend-registration#250
* Adjust changelog
* Add remarks to Company regex
* Update packages
---
CHANGELOG.md | 7 ++++++
.../Framework.Async/Directory.Build.props | 2 +-
.../Framework.Cors/Directory.Build.props | 2 +-
.../Framework.DBAccess/Directory.Build.props | 2 +-
.../Directory.Build.props | 2 +-
.../Directory.Build.props | 2 +-
.../Directory.Build.props | 2 +-
.../Directory.Build.props | 2 +-
.../Directory.Build.props | 2 +-
.../Directory.Build.props | 2 +-
.../Framework.IO/Directory.Build.props | 2 +-
.../Framework.Linq/Directory.Build.props | 2 +-
.../Framework.Logging/Directory.Build.props | 2 +-
.../Framework.Models/Directory.Build.props | 2 +-
.../Framework.Models/ValidationExpressions.cs | 12 +++++++++-
.../Framework.Seeding/Directory.Build.props | 2 +-
.../Framework.Swagger/Directory.Build.props | 2 +-
.../Framework.Token/Directory.Build.props | 2 +-
.../Framework.Web/Directory.Build.props | 2 +-
.../ValidationExpressionsTests.cs | 24 +++++++++++++++++++
20 files changed, 59 insertions(+), 18 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d7a0aecd86..867b6324c9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,13 @@
New features, fixed bugs, known defects and other noteworthy changes to each release of the Catena-X Portal Backend.
+## Unreleased
+
+## Feature
+
+* **Registration**
+ * adjust legalEntityPattern REGEX to allow all language characters [#1043](https://github.com/eclipse-tractusx/portal-backend/pull/1043)
+
## 2.3.0-alpha.2
## Feature
diff --git a/src/framework/Framework.Async/Directory.Build.props b/src/framework/Framework.Async/Directory.Build.props
index 59d8383e0c..cd99f1696a 100644
--- a/src/framework/Framework.Async/Directory.Build.props
+++ b/src/framework/Framework.Async/Directory.Build.props
@@ -19,7 +19,7 @@
- 2.10.0
+ 2.11.0
diff --git a/src/framework/Framework.Cors/Directory.Build.props b/src/framework/Framework.Cors/Directory.Build.props
index 59d8383e0c..cd99f1696a 100644
--- a/src/framework/Framework.Cors/Directory.Build.props
+++ b/src/framework/Framework.Cors/Directory.Build.props
@@ -19,7 +19,7 @@
- 2.10.0
+ 2.11.0
diff --git a/src/framework/Framework.DBAccess/Directory.Build.props b/src/framework/Framework.DBAccess/Directory.Build.props
index 59d8383e0c..cd99f1696a 100644
--- a/src/framework/Framework.DBAccess/Directory.Build.props
+++ b/src/framework/Framework.DBAccess/Directory.Build.props
@@ -19,7 +19,7 @@
- 2.10.0
+ 2.11.0
diff --git a/src/framework/Framework.DateTimeProvider/Directory.Build.props b/src/framework/Framework.DateTimeProvider/Directory.Build.props
index 59d8383e0c..cd99f1696a 100644
--- a/src/framework/Framework.DateTimeProvider/Directory.Build.props
+++ b/src/framework/Framework.DateTimeProvider/Directory.Build.props
@@ -19,7 +19,7 @@
- 2.10.0
+ 2.11.0
diff --git a/src/framework/Framework.DependencyInjection/Directory.Build.props b/src/framework/Framework.DependencyInjection/Directory.Build.props
index 59d8383e0c..cd99f1696a 100644
--- a/src/framework/Framework.DependencyInjection/Directory.Build.props
+++ b/src/framework/Framework.DependencyInjection/Directory.Build.props
@@ -19,7 +19,7 @@
- 2.10.0
+ 2.11.0
diff --git a/src/framework/Framework.ErrorHandling.Controller/Directory.Build.props b/src/framework/Framework.ErrorHandling.Controller/Directory.Build.props
index 59d8383e0c..cd99f1696a 100644
--- a/src/framework/Framework.ErrorHandling.Controller/Directory.Build.props
+++ b/src/framework/Framework.ErrorHandling.Controller/Directory.Build.props
@@ -19,7 +19,7 @@
- 2.10.0
+ 2.11.0
diff --git a/src/framework/Framework.ErrorHandling.Web/Directory.Build.props b/src/framework/Framework.ErrorHandling.Web/Directory.Build.props
index 59d8383e0c..cd99f1696a 100644
--- a/src/framework/Framework.ErrorHandling.Web/Directory.Build.props
+++ b/src/framework/Framework.ErrorHandling.Web/Directory.Build.props
@@ -19,7 +19,7 @@
- 2.10.0
+ 2.11.0
diff --git a/src/framework/Framework.ErrorHandling/Directory.Build.props b/src/framework/Framework.ErrorHandling/Directory.Build.props
index 59d8383e0c..cd99f1696a 100644
--- a/src/framework/Framework.ErrorHandling/Directory.Build.props
+++ b/src/framework/Framework.ErrorHandling/Directory.Build.props
@@ -19,7 +19,7 @@
- 2.10.0
+ 2.11.0
diff --git a/src/framework/Framework.HttpClientExtensions/Directory.Build.props b/src/framework/Framework.HttpClientExtensions/Directory.Build.props
index 59d8383e0c..cd99f1696a 100644
--- a/src/framework/Framework.HttpClientExtensions/Directory.Build.props
+++ b/src/framework/Framework.HttpClientExtensions/Directory.Build.props
@@ -19,7 +19,7 @@
- 2.10.0
+ 2.11.0
diff --git a/src/framework/Framework.IO/Directory.Build.props b/src/framework/Framework.IO/Directory.Build.props
index 59d8383e0c..cd99f1696a 100644
--- a/src/framework/Framework.IO/Directory.Build.props
+++ b/src/framework/Framework.IO/Directory.Build.props
@@ -19,7 +19,7 @@
- 2.10.0
+ 2.11.0
diff --git a/src/framework/Framework.Linq/Directory.Build.props b/src/framework/Framework.Linq/Directory.Build.props
index 59d8383e0c..cd99f1696a 100644
--- a/src/framework/Framework.Linq/Directory.Build.props
+++ b/src/framework/Framework.Linq/Directory.Build.props
@@ -19,7 +19,7 @@
- 2.10.0
+ 2.11.0
diff --git a/src/framework/Framework.Logging/Directory.Build.props b/src/framework/Framework.Logging/Directory.Build.props
index 59d8383e0c..cd99f1696a 100644
--- a/src/framework/Framework.Logging/Directory.Build.props
+++ b/src/framework/Framework.Logging/Directory.Build.props
@@ -19,7 +19,7 @@
- 2.10.0
+ 2.11.0
diff --git a/src/framework/Framework.Models/Directory.Build.props b/src/framework/Framework.Models/Directory.Build.props
index 59d8383e0c..cd99f1696a 100644
--- a/src/framework/Framework.Models/Directory.Build.props
+++ b/src/framework/Framework.Models/Directory.Build.props
@@ -19,7 +19,7 @@
- 2.10.0
+ 2.11.0
diff --git a/src/framework/Framework.Models/ValidationExpressions.cs b/src/framework/Framework.Models/ValidationExpressions.cs
index c4d265d744..b16a630321 100644
--- a/src/framework/Framework.Models/ValidationExpressions.cs
+++ b/src/framework/Framework.Models/ValidationExpressions.cs
@@ -24,6 +24,16 @@ public static class ValidationExpressions
public const string Name = @"^.+$";
public const string Bpn = @"^(BPNL|bpnl)[\w|\d]{12}$";
public const string Bpns = @"^(BPNS|bpns)[\w|\d]{12}$";
- public const string Company = @"^(?!.*\s$)([\wÀ-ÿ£$€¥¢@%*+\-/\\,.:;=<>!?&^#'\x22()[\]]\s?){1,160}$";
+ ///
+ /// Regular expression pattern for validating legal company names.
+ ///
+ ///
+ /// The pattern ensures the following:
+ /// - unicode category \p{L} for letters, \u0E00-\u0E7F for Thai characters
+ /// - digits, currency symbols, and various special characters.
+ /// - The string can have spaces between characters but not at the end.
+ /// - The length of the string must be between 1 and 160 characters.
+ ///
+ public const string Company = @"^(?!.*\s$)([\p{L}\u0E00-\u0E7F\d\p{Sc}@%*+_\-/\\,.:;=<>!?&^#'\x22()[\]]\s?){1,160}$";
public const string ExternalCertificateNumber = @"^[a-zA-Z0-9]{0,36}$";
}
diff --git a/src/framework/Framework.Seeding/Directory.Build.props b/src/framework/Framework.Seeding/Directory.Build.props
index 59d8383e0c..cd99f1696a 100644
--- a/src/framework/Framework.Seeding/Directory.Build.props
+++ b/src/framework/Framework.Seeding/Directory.Build.props
@@ -19,7 +19,7 @@
- 2.10.0
+ 2.11.0
diff --git a/src/framework/Framework.Swagger/Directory.Build.props b/src/framework/Framework.Swagger/Directory.Build.props
index 59d8383e0c..cd99f1696a 100644
--- a/src/framework/Framework.Swagger/Directory.Build.props
+++ b/src/framework/Framework.Swagger/Directory.Build.props
@@ -19,7 +19,7 @@
- 2.10.0
+ 2.11.0
diff --git a/src/framework/Framework.Token/Directory.Build.props b/src/framework/Framework.Token/Directory.Build.props
index 59d8383e0c..cd99f1696a 100644
--- a/src/framework/Framework.Token/Directory.Build.props
+++ b/src/framework/Framework.Token/Directory.Build.props
@@ -19,7 +19,7 @@
- 2.10.0
+ 2.11.0
diff --git a/src/framework/Framework.Web/Directory.Build.props b/src/framework/Framework.Web/Directory.Build.props
index 59d8383e0c..cd99f1696a 100644
--- a/src/framework/Framework.Web/Directory.Build.props
+++ b/src/framework/Framework.Web/Directory.Build.props
@@ -19,7 +19,7 @@
- 2.10.0
+ 2.11.0
diff --git a/tests/framework/Framework.Models.Tests/ValidationExpressionsTests.cs b/tests/framework/Framework.Models.Tests/ValidationExpressionsTests.cs
index 2e8f9f0d50..db31da7028 100644
--- a/tests/framework/Framework.Models.Tests/ValidationExpressionsTests.cs
+++ b/tests/framework/Framework.Models.Tests/ValidationExpressionsTests.cs
@@ -36,6 +36,11 @@ public class ValidationExpressionsTests
[InlineData("C", true)] // Minimum valid length
[InlineData("7-ELEVEN INTERNATIONAL LLC", true)]
[InlineData("Recht 24/7 Schröder Rechtsanwaltsgesellschaft mbH", true)]
+ [InlineData("ACE 9 SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ", true)]
+ [InlineData("GAMMO Europe Korlátolt Felelősségű Társaság", true)]
+ [InlineData("摩根亚太优势混合型证券投资基金 (QDII)", true)]
+ [InlineData("삼성", true)]
+ [InlineData("三", true)]
[InlineData("Currency £$€¥¢", true)]
[InlineData("Brackets []()", true)]
[InlineData("Punctuation !?,.;:", true)]
@@ -45,6 +50,25 @@ public class ValidationExpressionsTests
[InlineData("German: ÄÖÜß", true)]
[InlineData("+SEN Inc.", true)] // leading special character
[InlineData("Danish: ÆØÅ", true)]
+ [InlineData("Czech: ČĎŇŘŠŤŽŮů", true)]
+ [InlineData("Estonian: ÄÖÜŠŽ", true)]
+ [InlineData("Slovak: ĽĹŔŠŤŽ", true)]
+ [InlineData("Polish: ĄĆĘŁŃÓŚŹŻ", true)]
+ [InlineData("Hungarian: ÁÉÍÓÖŐÚÜŰ", true)]
+ [InlineData("Romanian: ÂÎŞŢ", true)]
+ [InlineData("Bulgarian: ЙЪЬ", true)]
+ [InlineData("Greek: ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ", true)]
+ [InlineData("Turkish: ÇĞİıÖŞÜ", true)]
+ [InlineData("Arabic: ابتثجحخدذرزسشصضطظعغفقكلمنهوي", true)]
+ [InlineData("Hebrew: שלום עולם", true)]
+ [InlineData("Hindi: अआइईउऊऋएऐओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलवशषस", true)]
+ [InlineData("Tamil: அஆஇஈஉஊஎஏஐஒஓஔகஙசஞடணதநனபமயரலவழளஷஸஹ", true)]
+ [InlineData("Japanese: あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをん", true)]
+ [InlineData("Chinese: 你好 世界", true)]
+ [InlineData("Korean: 안녕하세요 세계", true)]
+ [InlineData("Vietnamese: ăâắáấàằầảẳẩãẵẫạặậđêéếèềẻểẽễẹệíìỉĩịôơóốớòồờỏổởõỗỡọộợưúứùừủửũữụựýỳỷỹỵ", true)]
+ [InlineData("Singapore: 你好 世界", true)]
+ [InlineData("Thai: สวัสดีชาวโลก", true)]
[InlineData("Bayerische Motoren Werke Aktiengesellschaft ", false)] // Ends with whitespace
[InlineData(" Bayerische Motoren Werke Aktiengesellschaft", false)] // starts with whitespace
[InlineData("Bayerische Motoren Werke Aktiengesellschaft", false)] // double whitespace