Restrict umbral name to single word (no spaces)

Explicit space check with clear error message on both backend
validator and frontend client-side validation. The existing regex
already disallows spaces but the dedicated check gives a better UX.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Kyle 2026-03-04 05:03:22 +08:00
parent 6130d09ae8
commit 03abbbf8a7
2 changed files with 6 additions and 0 deletions

View File

@ -180,6 +180,8 @@ class ProfileUpdate(BaseModel):
if v is None:
return v
import re
if ' ' in v:
raise ValueError('Umbral name must be a single word with no spaces')
if not re.match(r'^[a-zA-Z0-9_-]{3,50}$', v):
raise ValueError('Umbral name must be 3-50 alphanumeric characters, hyphens, or underscores')
return v

View File

@ -227,6 +227,10 @@ export default function SettingsPage() {
// Client-side umbral name validation
if (field === 'umbral_name') {
if (current.includes(' ')) {
setUmbralNameError('Must be a single word with no spaces');
return;
}
if (!current || !/^[a-zA-Z0-9_-]{3,50}$/.test(current)) {
setUmbralNameError('3-50 characters: letters, numbers, hyphens, underscores');
return;