diff --git a/app/features/tournament/tournament-schemas.server.ts b/app/features/tournament/tournament-schemas.server.ts index dc50520cc..26b2d80c3 100644 --- a/app/features/tournament/tournament-schemas.server.ts +++ b/app/features/tournament/tournament-schemas.server.ts @@ -163,7 +163,9 @@ export const adminActionSchema = z.union([ }), z.object({ _action: _action("UPDATE_IN_GAME_NAME"), - inGameNameText: z.string().max(USER.IN_GAME_NAME_TEXT_MAX_LENGTH), + inGameNameText: z + .string() + .refine((val) => [...val].length <= USER.IN_GAME_NAME_TEXT_MAX_LENGTH), inGameNameDiscriminator: z .string() .refine((val) => /^[0-9a-z]{4,5}$/.test(val)), diff --git a/app/features/user-page/user-page-constants.test.ts b/app/features/user-page/user-page-constants.test.ts index bffba2a92..ed9c25735 100644 --- a/app/features/user-page/user-page-constants.test.ts +++ b/app/features/user-page/user-page-constants.test.ts @@ -10,6 +10,7 @@ describe("IN_GAME_NAME_REGEXP", () => { "A#1234", "Player#abcd", "名前テスト1234#ab12c", + "☆CR☆Sh𝓔𝓔p!#1234", ]; for (const name of validNames) { @@ -28,6 +29,7 @@ describe("IN_GAME_NAME_REGEXP", () => { "Sendou#123456", "Sendou#ABCD", "12345678901#1234", + "𝓔𝓔𝓔𝓔𝓔𝓔𝓔𝓔𝓔𝓔𝓔#1234", ]; for (const name of invalidNames) { diff --git a/app/features/user-page/user-page-constants.ts b/app/features/user-page/user-page-constants.ts index 3dd0d98d3..da12fe0eb 100644 --- a/app/features/user-page/user-page-constants.ts +++ b/app/features/user-page/user-page-constants.ts @@ -18,7 +18,7 @@ export const USER = { GAME_BADGES_SMALL_MAX: 4, }; -export const IN_GAME_NAME_REGEXP = /^.{1,10}#[0-9a-z]{4,5}$/; +export const IN_GAME_NAME_REGEXP = /^.{1,10}#[0-9a-z]{4,5}$/u; export const MATCHES_PER_SEASONS_PAGE = 8; export const RESULTS_PER_PAGE = 25; diff --git a/app/features/user-page/user-page-schemas.ts b/app/features/user-page/user-page-schemas.ts index e4409a096..244a98ae1 100644 --- a/app/features/user-page/user-page-schemas.ts +++ b/app/features/user-page/user-page-schemas.ts @@ -101,7 +101,10 @@ export const userEditProfileBaseSchema = z.object({ inGameName: textFieldOptional({ label: "labels.profileInGameName", bottomText: "bottomTexts.profileInGameName", - maxLength: 10 + 1 + 5, // 10 for name, 1 for #, 5 for discriminator + maxLength: + USER.IN_GAME_NAME_TEXT_MAX_LENGTH + + 1 + + USER.IN_GAME_NAME_DISCRIMINATOR_MAX_LENGTH, regExp: { pattern: IN_GAME_NAME_REGEXP, message: "forms:errors.profileInGameName",