Skip to content

fix(condo): DOMA-12068 add profile name char check#7228

Open
condo-bot wants to merge 2 commits intomainfrom
codex/fix-validation-bug-for-special-characters
Open

fix(condo): DOMA-12068 add profile name char check#7228
condo-bot wants to merge 2 commits intomainfrom
codex/fix-validation-bug-for-special-characters

Conversation

@condo-bot
Copy link
Member

@condo-bot condo-bot commented Feb 20, 2026

Motivation

  • Fix validation bug in the user profile edit form so full name cannot contain forbidden special characters (digits/symbols/etc.) which previously passed unnoticed.

Description

  • Add localized field.FullName.invalidChar message and wire the existing specCharValidator from useValidations into the name field rules in UserProfileForm so the required/min/max checks are preserved and an additional forbidden-character check is applied.

Testing

  • Ran yarn eslint apps/condo/domains/user/components/UserProfileForm.tsx, which completed with warnings but no errors.
  • Attempted a Playwright navigation to http://localhost:3000/user/edit to capture a screenshot, but it failed with net::ERR_EMPTY_RESPONSE because the local app was not available.

Codex Task

Summary by CodeRabbit

Bug Fixes

  • Improved user profile name field validation to detect and reject invalid special characters with a localized error message for better user guidance.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 20, 2026

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk
  • The change adds a validation rule using an existing, tested validator that is already used in similar contexts throughout the codebase. The localization is properly implemented across all language files. The only issue is a minor style inconsistency (missing space after colon) that does not affect functionality.
  • No files require special attention

Important Files Changed

Filename Overview
apps/condo/domains/user/components/UserProfileForm.tsx Added specCharValidator to full name field to prevent special characters/digits, includes proper localization

Last reviewed commit: 9136a5b

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

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' })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 5, 2026

📝 Walkthrough

Walkthrough

Added special character validation to the user name field in the profile form component. The validation uses a specCharValidator from the useValidations hook and includes a new localization message for invalid character errors. Validation rules for the name field now include required, length, and character-type checks.

Changes

Cohort / File(s) Summary
Name Field Validation Enhancement
apps/condo/domains/user/components/UserProfileForm.tsx
Introduced specCharValidator to validate special characters in the name field alongside existing required and length validations. Added FullNameInvalidCharMessage localization string for user-facing validation error messages.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A name so fine, let's make it shine,
With validation rules, character by character,
No funky symbols in this line,
The form now knows what's proper and right!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a special character validation check to the profile name field in the condo application.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/fix-validation-bug-for-special-characters

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 92f9284 and c2803f0.

📒 Files selected for processing (1)
  • apps/condo/domains/user/components/UserProfileForm.tsx

Comment on lines +201 to 207
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],
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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.

Suggested change
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).

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 5, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants