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:
parent
6130d09ae8
commit
03abbbf8a7
@ -180,6 +180,8 @@ class ProfileUpdate(BaseModel):
|
|||||||
if v is None:
|
if v is None:
|
||||||
return v
|
return v
|
||||||
import re
|
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):
|
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')
|
raise ValueError('Umbral name must be 3-50 alphanumeric characters, hyphens, or underscores')
|
||||||
return v
|
return v
|
||||||
|
|||||||
@ -227,6 +227,10 @@ export default function SettingsPage() {
|
|||||||
|
|
||||||
// Client-side umbral name validation
|
// Client-side umbral name validation
|
||||||
if (field === 'umbral_name') {
|
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)) {
|
if (!current || !/^[a-zA-Z0-9_-]{3,50}$/.test(current)) {
|
||||||
setUmbralNameError('3-50 characters: letters, numbers, hyphens, underscores');
|
setUmbralNameError('3-50 characters: letters, numbers, hyphens, underscores');
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user