-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[WEB-4434]fix: user name validation #7617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
33d3e03
fde6de3
43cdaec
4e4e3ef
9ef0de4
03bbe79
56795bb
04e14f3
00e38a7
b4acaa2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -213,6 +213,11 @@ export const ProfileSetupStep: FC<Props> = observer(({ handleStepChange }) => { | |||||||||||||||||||||||||||
| value: 24, | ||||||||||||||||||||||||||||
| message: "Name must be within 24 characters.", | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| validate: (value) => { | ||||||||||||||||||||||||||||
| if (!/^[a-zA-Z0-9 _-]+$/.test(value)) | ||||||||||||||||||||||||||||
| return "First name can only contain letters, numbers, hyphens, and underscores."; | ||||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
|
Comment on lines
+216
to
+220
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainAlign rule with copy and block whitespace-only names Message says “First name” though label is “Name”, and you allow spaces but don’t mention them; also accepts only-spaces. Trim and update message. - validate: (value) => {
- if (!/^[a-zA-Z0-9 _-]+$/.test(value))
- return "First name can only contain letters, numbers, hyphens, and underscores.";
- return true;
- },
+ validate: (value) => {
+ const v = value.trim();
+ if (v.length === 0) return "Name can't be empty or only spaces.";
+ if (!/^[A-Za-z0-9 _-]+$/.test(v))
+ return "Name can only contain letters, numbers, spaces, hyphens (-), and underscores (_).";
+ return true;
+ },If the PR removes last name in onboarding, also delete it from:
🏁 Script executed: #!/bin/bash
# Find remaining onboarding references to last_name
rg -nP -C2 '\blast_name\b' apps/web/core/components/onboardingLength of output: 8338 Update name validation to trim whitespace and align message copy apps/web/core/components/onboarding/steps/profile/root.tsx (lines 216–220): - validate: (value) => {
- if (!/^[a-zA-Z0-9 _-]+$/.test(value))
- return "First name can only contain letters, numbers, hyphens, and underscores.";
- return true;
- },
+ validate: (value) => {
+ const trimmed = value.trim();
+ if (trimmed.length === 0) return "Name can't be empty or only spaces.";
+ if (!/^[A-Za-z0-9 _-]+$/.test(trimmed))
+ return "Name can only contain letters, numbers, spaces, hyphens (-), and underscores (_).";
+ return true;
+ },📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| }} | ||||||||||||||||||||||||||||
| render={({ field: { value, onChange, ref } }) => ( | ||||||||||||||||||||||||||||
| <input | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.