fix: update Zod password regex to accept all special characters#568
fix: update Zod password regex to accept all special characters#568SUMIQVERSE wants to merge 2 commits into
Conversation
✅ Deploy Preview for github-spy ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughUpdated the signup password validation regex to a lookahead-based pattern that requires lowercase, uppercase, digit, and a non-word/non-whitespace character and enforces a minimum length of 8, allowing a broader set of special characters. ChangesPassword Validation Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
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)
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.
🎉 Thank you @SUMIQVERSE for your contribution. Please make sure your PR follows https://github.com/GitMetricsLab/github_tracker/blob/main/CONTRIBUTING.md#-pull-request-guidelines
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@backend/validators/authValidator.js`:
- Around line 20-22: The password regex in the .regex(...) call in
authValidator.js uses [\W_] which counts whitespace as a "special" character;
replace the fourth positive lookahead with one that requires a non-alphanumeric,
non-whitespace character (for example (?=.*[^A-Za-z0-9\s])) so the full pattern
becomes /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z0-9\s]).{8,}$/ to prevent
spaces/tabs from satisfying the special-character requirement.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 17259622-bf87-42bc-94db-198228a4cc91
📒 Files selected for processing (1)
backend/validators/authValidator.js
|
@coderabbitai resolve |
✅ Actions performedComments resolved. Approval is disabled; enable |
Related Issue
Description
Fixed a bug in the backend authentication validation logic where valid passwords containing certain special characters (like
#,^,-) were being incorrectly rejected during signup.The Zod validation schema previously used a restrictive regex
[@$!%*?&]that hardcoded a limited list of allowed special characters. I updated the regex to use[\W_], which universally accepts all standard special characters while maintaining the required security constraints (min 8 chars, uppercase, lowercase, number, and special character).How Has This Been Tested?
#symbol (e.g.,Jps@#1357).400 Bad Requestvalidation error no longer occurs and the account is created successfully.Type of Change
Summary by CodeRabbit