mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-08-26 04:57:08 -05:00
Disallow empty custom user names
This commit is contained in:
@@ -3,10 +3,16 @@ import type { BuildAbilitiesTupleWithUnknown } from "./modules/in-game-lists";
|
||||
export const TWEET_LENGTH_MAX_LENGTH = 280;
|
||||
export const DISCORD_MESSAGE_MAX_LENGTH = 2000;
|
||||
|
||||
const EMPTY_CHARACTERS = ["\u200B", "\u200C", "\u200D", "\u200E", "\u200F"];
|
||||
export const notAllEmptyCharactersRegExp = new RegExp(
|
||||
`^(?!(${EMPTY_CHARACTERS.join("|")})+$).*$`,
|
||||
);
|
||||
|
||||
export const USER = {
|
||||
BIO_MAX_LENGTH: DISCORD_MESSAGE_MAX_LENGTH,
|
||||
CUSTOM_URL_MAX_LENGTH: 32,
|
||||
CUSTOM_NAME_MAX_LENGTH: 32,
|
||||
CUSTOM_NAME_REGEXP: notAllEmptyCharactersRegExp,
|
||||
BATTLEFY_MAX_LENGTH: 32,
|
||||
BSKY_MAX_LENGTH: 50,
|
||||
IN_GAME_NAME_TEXT_MAX_LENGTH: 20,
|
||||
|
||||
@@ -88,7 +88,12 @@ const userEditActionSchema = z
|
||||
),
|
||||
customName: z.preprocess(
|
||||
falsyToNull,
|
||||
z.string().trim().max(USER.CUSTOM_NAME_MAX_LENGTH).nullable(),
|
||||
z
|
||||
.string()
|
||||
.trim()
|
||||
.regex(USER.CUSTOM_NAME_REGEXP)
|
||||
.max(USER.CUSTOM_NAME_MAX_LENGTH)
|
||||
.nullable(),
|
||||
),
|
||||
battlefy: z.preprocess(
|
||||
falsyToNull,
|
||||
|
||||
Reference in New Issue
Block a user