Skip to content

Commit

Permalink
feat(validation): update Company validation expression (#1043)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
typecastcloud authored Oct 14, 2024
1 parent 1b0d423 commit 5765e4d
Show file tree
Hide file tree
Showing 20 changed files with 59 additions and 18 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/framework/Framework.Async/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/framework/Framework.Cors/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/framework/Framework.DBAccess/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/framework/Framework.IO/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/framework/Framework.Linq/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/framework/Framework.Logging/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/framework/Framework.Models/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
12 changes: 11 additions & 1 deletion src/framework/Framework.Models/ValidationExpressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}$";
/// <summary>
/// Regular expression pattern for validating legal company names.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
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}$";
}
2 changes: 1 addition & 1 deletion src/framework/Framework.Seeding/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/framework/Framework.Swagger/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/framework/Framework.Token/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/framework/Framework.Web/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>2.10.0</VersionPrefix>
<VersionPrefix>2.11.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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
Expand Down

0 comments on commit 5765e4d

Please sign in to comment.