Skip to content

Commit

Permalink
Add regex for accented chars
Browse files Browse the repository at this point in the history
  • Loading branch information
sourcecodedeveloper committed Dec 24, 2023
1 parent e89e466 commit f4708f9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,7 @@ const CONST = {
DIGITS_AND_PLUS: /^\+?[0-9]*$/,
ALPHABETIC_AND_LATIN_CHARS: /^[\p{Script=Latin} ]*$/u,
NON_ALPHABETIC_AND_NON_LATIN_CHARS: /[^\p{Script=Latin}]/gu,
ACCENT_LATIN_CHARS: /[\u00C0-\u017F]/g,
POSITIVE_INTEGER: /^\d+$/,
PO_BOX: /\b[P|p]?(OST|ost)?\.?\s*[O|o|0]?(ffice|FFICE)?\.?\s*[B|b][O|o|0]?[X|x]?\.?\s+[#]?(\d+)\b/,
ANY_VALUE: /^.+$/,
Expand Down
3 changes: 2 additions & 1 deletion src/libs/ValidationUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ function isValidDisplayName(name: string): boolean {
* Checks that the provided legal name doesn't contain special characters
*/
function isValidLegalName(name: string): boolean {
return CONST.REGEX.ALPHABETIC_AND_LATIN_CHARS.test(name);
const hasAccentedChars = Boolean(name.match(CONST.REGEX.ACCENT_LATIN_CHARS));
return CONST.REGEX.ALPHABETIC_AND_LATIN_CHARS.test(name) && !hasAccentedChars;
}

/**
Expand Down

0 comments on commit f4708f9

Please sign in to comment.