Repository navigation
fix: improve country name validation - #2405
Nithya-3035 wants to merge 1 commit into
Conversation
Updated `backend/utils/nameCountry.js` to improve country name validation and normalization.
- Added Unicode normalization using `normalize("NFKC")`.
- Improved whitespace handling by trimming leading and trailing spaces.
- Added support for multiple consecutive spaces.
- Implemented case-insensitive country matching.
- Used a `Set` for faster country lookup.
- Added input type checking to reject non-string and empty values.
- Exported the country list as a frozen array.
- Preserved the existing `isValidCountry` function for compatibility.
These changes improve validation consistency, readability, and lookup performance.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 46 minutes. View limit details
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. |
|
Thank you for submitting your pull request, @Nithya-3035! 🙌 |
|
Improved country name validation by adding Unicode normalization, whitespace handling, and case-insensitive matching. Also optimized country lookups using a Set and added input type validation to handle invalid values safely. |
Updated
backend/utils/nameCountry.jsto improve country name validation and normalization.normalize("NFKC").Setfor faster country lookup.isValidCountryfunction for compatibility.These changes improve validation consistency, readability, and lookup performance.
📝 Pull Request Description
Related Issue
Closes #
Summary
Provide a short, reviewer-friendly summary of what changed and why.
Type of Change
How Has This Been Tested?
Describe the testing steps performed.
Screenshots (if applicable)
Add screenshots or videos to demonstrate the changes.
Checklist