allowing spaces in display name#9121
Conversation
📝 WalkthroughWalkthroughThe PR updates display name validation to allow space characters. The regex pattern in Display Name Validation Update
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/utils/src/validation.ts (2)
86-95:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winUpdate JSDoc example to reflect that spaces are now allowed.
The example explicitly states that
"john doe"returns an error because spaces are not allowed, but this is no longer true.📝 Proposed fix
/** * `@description` Validates display names and usernames * `@param` {string} displayName - Display name to validate * `@returns` {boolean | string} true if valid, error message if invalid * `@example` * validateDisplayName("john_doe") // returns true * validateDisplayName("john.doe-123") // returns true - * validateDisplayName("john doe") // returns error message (spaces not allowed) + * validateDisplayName("john doe") // returns true * validateDisplayName("john<>doe") // returns error message */🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/utils/src/validation.ts` around lines 86 - 95, Update the JSDoc examples for validateDisplayName to reflect that spaces are permitted: replace the example showing validateDisplayName("john doe") returning an error with one that shows it returns true (e.g., validateDisplayName("john doe") // returns true), and ensure any other example descriptions mention spaces are allowed rather than disallowed so the docstring matches the current validation behavior.
28-33:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winUpdate documentation comment to reflect that spaces are now allowed.
The comment explicitly states "Blocks: Spaces and injection-risk characters" but the regex now permits spaces. This inconsistency will confuse future maintainers.
📝 Proposed fix
/** * Display Name Pattern (for display_name, usernames) - * Allows: Unicode letters (\p{L}), numbers (\p{N}), underscore, period, hyphen - * Use case: International usernames like "josé_123", "李明.dev", "müller-2024" - * Blocks: Spaces and injection-risk characters + * Allows: Unicode letters (\p{L}), numbers (\p{N}), spaces, underscore, period, hyphen + * Use case: International usernames like "josé_123", "李明.dev", "müller-2024", "JJ KK" + * Blocks: Injection-risk characters */🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/utils/src/validation.ts` around lines 28 - 33, Update the documentation comment for the Display Name Pattern to reflect that spaces are allowed by the current regex (remove "Blocks: Spaces" and instead list "Allows: spaces" or "Allows: spaces and ..." and keep mention of injection-risk characters as still blocked); locate the comment tied to the Display Name Pattern / display_name regex (e.g., the constant or variable used for the display name pattern) and edit the comment text so it accurately describes allowed characters (Unicode letters, numbers, underscore, period, hyphen, and spaces) and what is blocked.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@packages/utils/src/validation.ts`:
- Around line 86-95: Update the JSDoc examples for validateDisplayName to
reflect that spaces are permitted: replace the example showing
validateDisplayName("john doe") returning an error with one that shows it
returns true (e.g., validateDisplayName("john doe") // returns true), and ensure
any other example descriptions mention spaces are allowed rather than disallowed
so the docstring matches the current validation behavior.
- Around line 28-33: Update the documentation comment for the Display Name
Pattern to reflect that spaces are allowed by the current regex (remove "Blocks:
Spaces" and instead list "Allows: spaces" or "Allows: spaces and ..." and keep
mention of injection-risk characters as still blocked); locate the comment tied
to the Display Name Pattern / display_name regex (e.g., the constant or variable
used for the display name pattern) and edit the comment text so it accurately
describes allowed characters (Unicode letters, numbers, underscore, period,
hyphen, and spaces) and what is blocked.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 74377212-6ac5-44df-b1ff-18b234b0bff7
📒 Files selected for processing (1)
packages/utils/src/validation.ts
Description
Fixes the issue #9112
We were not allowed to enter spaces in display name, changed the regex so we can now.
Type of Change
Screenshots and Media (if applicable)
Test Scenarios
References
(#9112)
Summary by CodeRabbit