Disallow non latin characters team name (#433)
* feat: add validation for team names to restrict non-Latin characters - Implemented a new test case to ensure team accounts cannot be created using non-Latin characters, including Cyrillic, Chinese, Japanese, Arabic, and emoji. - Updated the team name schema to include a regex validation for Latin characters only. - Added corresponding error message in the localization file for non-Latin character restrictions. * chore: bump version to 2.21.18 in package.json
This commit is contained in:
committed by
GitHub
parent
c4a961e93d
commit
43038034fd
@@ -14,6 +14,11 @@ const RESERVED_NAMES_ARRAY = [
|
||||
|
||||
const SPECIAL_CHARACTERS_REGEX = /[!@#$%^&*()+=[\]{};':"\\|,.<>/?]/;
|
||||
|
||||
/**
|
||||
* Regex that matches only Latin characters (a-z, A-Z), numbers, spaces, and hyphens
|
||||
*/
|
||||
const LATIN_ONLY_REGEX = /^[a-zA-Z0-9\s-]+$/;
|
||||
|
||||
/**
|
||||
* @name TeamNameSchema
|
||||
*/
|
||||
@@ -31,6 +36,14 @@ export const TeamNameSchema = z
|
||||
message: 'teams:specialCharactersError',
|
||||
},
|
||||
)
|
||||
.refine(
|
||||
(name) => {
|
||||
return LATIN_ONLY_REGEX.test(name);
|
||||
},
|
||||
{
|
||||
message: 'teams:nonLatinCharactersError',
|
||||
},
|
||||
)
|
||||
.refine(
|
||||
(name) => {
|
||||
return !RESERVED_NAMES_ARRAY.includes(name.toLowerCase());
|
||||
|
||||
Reference in New Issue
Block a user