make username and coin name alphanumerical only

This commit is contained in:
Face 2025-05-31 12:58:24 +03:00
parent 8d12c679ae
commit c2208335a5
2 changed files with 16 additions and 0 deletions

View file

@ -24,6 +24,13 @@ async function validateInputs(name: string, bio: string, username: string, avata
throw error(400, 'Username must be between 3 and 30 characters');
}
if (username) {
const alphanumericRegex = /^[a-zA-Z0-9]+$/;
if (!alphanumericRegex.test(username)) {
throw error(400, 'Username must contain only letters and numbers');
}
}
if (username && !(await isNameAppropriate(username))) {
throw error(400, 'Username contains inappropriate content');
}