fix(condo): DOMA-12068 add profile name char check#7228
fix(condo): DOMA-12068 add profile name char check#7228
Conversation
Confidence Score: 4/5
Important Files Changed
Last reviewed commit: 9136a5b |
| const ApplyChangesMessage = intl.formatMessage({ id: 'ApplyChanges' }) | ||
| const MinLengthError = intl.formatMessage({ id: 'field.ClientName.minLengthError' }) | ||
| const MaxLengthError = intl.formatMessage({ id: 'field.ClientName.maxLengthError' }) | ||
| const FullNameInvalidCharMessage = intl.formatMessage({ id:'field.FullName.invalidChar' }) |
There was a problem hiding this comment.
Missing space after colon in id: (should be id: )
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
📝 WalkthroughWalkthroughAdded special character validation to the user name field in the profile form component. The validation uses a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/condo/domains/user/components/UserProfileForm.tsx`:
- Around line 201-207: The name field validation currently uses
requiredValidator, specCharValidator, minClientNameRule, and maxClientNameRule
but misses trimValidator, allowing whitespace-only names to pass; update the
validations object returned by useValidations() to include trimValidator in the
name rules (e.g., add trimValidator before requiredValidator or alongside it) so
whitespace-only input is rejected, following the same pattern used in
CreateEmployeeForm (keep using changeMessage wrappers for error messages where
applicable).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ef958b21-2d1f-473f-b1a9-6966d5b55630
📒 Files selected for processing (1)
apps/condo/domains/user/components/UserProfileForm.tsx
| const { requiredValidator, emailValidator, changeMessage, minLengthValidator, maxLengthValidator, specCharValidator } = useValidations() | ||
| const minClientNameRule = changeMessage(minLengthValidator(2), MinLengthError) | ||
| const maxClientNameRule = changeMessage(maxLengthValidator(100), MaxLengthError) | ||
| const validations = { | ||
| email: [emailValidator], | ||
| name: [requiredValidator, minClientNameRule, maxClientNameRule], | ||
| name: [requiredValidator, changeMessage(specCharValidator, FullNameInvalidCharMessage), minClientNameRule, maxClientNameRule], | ||
| } |
There was a problem hiding this comment.
Add trimValidator to prevent whitespace-only names from passing validation.
On Line 206, specCharValidator allows spaces, so whitespace-only input can pass character checks and then be trimmed to '' in formAction, resulting in a silent no-op update. Please add trimValidator to name rules (same pattern used in apps/condo/domains/organization/components/EmployeeForm/CreateEmployeeForm.tsx).
Suggested patch
- const { requiredValidator, emailValidator, changeMessage, minLengthValidator, maxLengthValidator, specCharValidator } = useValidations()
+ const { requiredValidator, emailValidator, changeMessage, minLengthValidator, maxLengthValidator, trimValidator, specCharValidator } = useValidations()
@@
- name: [requiredValidator, changeMessage(specCharValidator, FullNameInvalidCharMessage), minClientNameRule, maxClientNameRule],
+ name: [
+ requiredValidator,
+ trimValidator,
+ changeMessage(specCharValidator, FullNameInvalidCharMessage),
+ minClientNameRule,
+ maxClientNameRule,
+ ],📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const { requiredValidator, emailValidator, changeMessage, minLengthValidator, maxLengthValidator, specCharValidator } = useValidations() | |
| const minClientNameRule = changeMessage(minLengthValidator(2), MinLengthError) | |
| const maxClientNameRule = changeMessage(maxLengthValidator(100), MaxLengthError) | |
| const validations = { | |
| email: [emailValidator], | |
| name: [requiredValidator, minClientNameRule, maxClientNameRule], | |
| name: [requiredValidator, changeMessage(specCharValidator, FullNameInvalidCharMessage), minClientNameRule, maxClientNameRule], | |
| } | |
| const { requiredValidator, emailValidator, changeMessage, minLengthValidator, maxLengthValidator, trimValidator, specCharValidator } = useValidations() | |
| const minClientNameRule = changeMessage(minLengthValidator(2), MinLengthError) | |
| const maxClientNameRule = changeMessage(maxLengthValidator(100), MaxLengthError) | |
| const validations = { | |
| email: [emailValidator], | |
| name: [ | |
| requiredValidator, | |
| trimValidator, | |
| changeMessage(specCharValidator, FullNameInvalidCharMessage), | |
| minClientNameRule, | |
| maxClientNameRule, | |
| ], | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/condo/domains/user/components/UserProfileForm.tsx` around lines 201 -
207, The name field validation currently uses requiredValidator,
specCharValidator, minClientNameRule, and maxClientNameRule but misses
trimValidator, allowing whitespace-only names to pass; update the validations
object returned by useValidations() to include trimValidator in the name rules
(e.g., add trimValidator before requiredValidator or alongside it) so
whitespace-only input is rejected, following the same pattern used in
CreateEmployeeForm (keep using changeMessage wrappers for error messages where
applicable).
|



Motivation
Description
field.FullName.invalidCharmessage and wire the existingspecCharValidatorfromuseValidationsinto thenamefield rules inUserProfileFormso the required/min/max checks are preserved and an additional forbidden-character check is applied.Testing
yarn eslint apps/condo/domains/user/components/UserProfileForm.tsx, which completed with warnings but no errors.http://localhost:3000/user/editto capture a screenshot, but it failed withnet::ERR_EMPTY_RESPONSEbecause the local app was not available.Codex Task
Summary by CodeRabbit
Bug Fixes