workspaces to dashboards, imap email sync, ffmpeg tool, tts fix, file browser refresh, automation sidebar reorder
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import * as errors from '@@/custom-errors';
|
||||
|
||||
export function validateUsername(username: string | undefined): string {
|
||||
if (!username || !username.trim()) {
|
||||
throw errors.BAD_REQUEST('Username is required');
|
||||
}
|
||||
|
||||
const trimmed = username.trim();
|
||||
|
||||
if (trimmed.includes('@')) {
|
||||
throw errors.BAD_REQUEST('Username cannot be an email address');
|
||||
}
|
||||
|
||||
if (trimmed.length < 2 || trimmed.length > 32) {
|
||||
throw errors.BAD_REQUEST('Username must be between 2 and 32 characters');
|
||||
}
|
||||
|
||||
if (!/^[a-zA-Z0-9._-]+$/.test(trimmed)) {
|
||||
throw errors.BAD_REQUEST('Username can only contain letters, numbers, dots, hyphens, and underscores');
|
||||
}
|
||||
|
||||
return trimmed;
|
||||
}
|
||||
Reference in New Issue
Block a user