From 194a81c4283053fd99b4541b0c8d3bfe8ad942dc Mon Sep 17 00:00:00 2001 From: Jordan Gerada <138688996+JordanGerada3@users.noreply.github.com> Date: Mon, 19 Aug 2024 15:16:48 +0200 Subject: [PATCH] feat: REGEX to allow long company names in BP invite (#1007) --- src/types/Patterns.test.ts | 17 ++++++++++++----- src/types/Patterns.ts | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/types/Patterns.test.ts b/src/types/Patterns.test.ts index 416edda81..9e25266cb 100644 --- a/src/types/Patterns.test.ts +++ b/src/types/Patterns.test.ts @@ -144,16 +144,23 @@ const TESTDATA = { 'BMW.Mini', 'BMW&Mini', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + '1234567890'.repeat(16), + 'Bayerische Motoren Werke Aktiengesellschaft', + '7-ELEVEN INTERNATIONAL LLC', + '5N Plus Lübeck GmbH', + 'Recht 24/7 Schröder Rechtsanwaltsgesellschaft mbH', + '+SEN Inc.', // leading special character + 'La Poste S.A.', + 'JPMORGAN ASIA-PACIFIC ADVANTAGE HYBRID FUND (QDII)', + 'Currency £$€¥¢', ], invalid: [ ' BMW', 'BMW TG', 'BMW ', - '123', - '!#@', - 'BMW/Mini]]', - 'BMW]]', - 'aaaaaaaaaaaa aaaaaaaaaaaaaaaaaa', + 'Bayerische Motoren Werke Aktiengesellschaft\n', // newline + 'W'.repeat(161), // 161 characters + '', // empty ], }, CNAMES: { diff --git a/src/types/Patterns.ts b/src/types/Patterns.ts index 961b450d1..d8a38773c 100644 --- a/src/types/Patterns.ts +++ b/src/types/Patterns.ts @@ -45,7 +45,7 @@ export const Patterns = { UUID: /^[a-f0-9]{8}(-[a-f0-9]{4}){4}[a-f0-9]{8}$/i, EXTID: /^[a-z0-9]{6,36}$/i, COMPANY_NAME: - /^\d*?[a-zÀ-ÿ]\d?([a-z0-9À-ÿ!?@&_£$€¥\-.,:;'()*+#%=]\s?){2,40}$/i, + /^(?!.*\s$)([\wÀ-ÿ£$€¥¢@%*+\-/\\,.:;=<>!?&^#'\x22()[\]]\s?){1,160}$/, name: /^([A-Za-zÀ-ÿ-,.'](?!.*[-,.]{2})[A-Za-zÀ-ÿ-,.']{1,40} ?)[^ –]{1,40}$/, zipcode: /^[A-Z0-9-]{1,8}$/, streetNumber: /^[0-9A-Za-z- ]{1,20}$/,