fix: correct error message for clan tag length (BUG-07) (#3946)

## Description:

The code was checking `clanTag.length > MAX_CLAN_TAG_LENGTH` but
returning `"tag_too_short"`. This fix corrects the error message to
something more appropriate or ensures the logic matches the message.

**Fix:** Corrected the error message key from `"tag_too_short"` to
`"tag_too_long"` when the length exceeds the maximum.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
## Please put your Discord username so you can be contacted if a bug or
regression is found:

barfires

Co-authored-by: Ryan <7389646+ryanbarlow97@users.noreply.github.com>
This commit is contained in:
Berk
2026-05-16 21:19:25 +03:00
committed by GitHub
parent 749f496318
commit 4460367682
3 changed files with 3 additions and 2 deletions
+1
View File
@@ -573,6 +573,7 @@
"invalid_chars": "Username can only contain letters, numbers, spaces, and underscores.", "invalid_chars": "Username can only contain letters, numbers, spaces, and underscores.",
"tag": "TAG", "tag": "TAG",
"tag_too_short": "Clan tag must be 2-5 alphanumeric characters.", "tag_too_short": "Clan tag must be 2-5 alphanumeric characters.",
"tag_too_long": "Clan tag cannot exceed 5 characters.",
"tag_invalid_chars": "Clan tag can only contain letters and numbers." "tag_invalid_chars": "Clan tag can only contain letters and numbers."
}, },
"host_modal": { "host_modal": {
+1 -1
View File
@@ -58,7 +58,7 @@ export function validateClanTag(clanTag: string): {
return { isValid: false, error: translateText("username.tag_too_short") }; return { isValid: false, error: translateText("username.tag_too_short") };
} }
if (clanTag.length > MAX_CLAN_TAG_LENGTH) { if (clanTag.length > MAX_CLAN_TAG_LENGTH) {
return { isValid: false, error: translateText("username.tag_too_short") }; return { isValid: false, error: translateText("username.tag_too_long") };
} }
const parsed = ClanTagSchema.safeParse(clanTag); const parsed = ClanTagSchema.safeParse(clanTag);
+1 -1
View File
@@ -63,7 +63,7 @@ describe("username.ts functions", () => {
test("rejects too long clan tag", () => { test("rejects too long clan tag", () => {
const res = validateClanTag("A".repeat(MAX_CLAN_TAG_LENGTH + 1)); const res = validateClanTag("A".repeat(MAX_CLAN_TAG_LENGTH + 1));
expect(res.isValid).toBe(false); expect(res.isValid).toBe(false);
expect(res.error).toBe("username.tag_too_short"); expect(res.error).toBe("username.tag_too_long");
}); });
test("accepts valid clan tag", () => { test("accepts valid clan tag", () => {