-
Notifications
You must be signed in to change notification settings - Fork 19
Allow digits in organization names for create/update in v1 validator #832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow digits in organization names for create/update in v1 validator #832
Conversation
WalkthroughValidation logic in src/validators/v1/organization.js was updated to permit digits in organization names. The regular expression for both create and update flows changed from allowing only letters and spaces to allowing letters, digits, and spaces. No other code paths, exports, or messages were modified. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Client
participant API as API Endpoint
participant V as Organization Validator
participant S as Service
C->>API: Create/Update Organization (name)
API->>V: Validate name
alt Name matches /^[A-Za-z0-9 ]+$/
V-->>API: Valid
API->>S: Proceed with create/update
S-->>API: Success
API-->>C: 2xx Response
else Name invalid
V-->>API: Error
API-->>C: 4xx Validation Error
end
note over V: Changed rule: digits now allowed in name
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/validators/v1/organization.js (1)
50-51: Mirror the same constraints for update flowKeep create/update consistent: add the same length check and clearer message here.
.withMessage('name field is empty') + .isLength({ min: 2, max: 100 }) + .withMessage('name must be 2-100 characters') - .matches(/^[A-Za-z0-9 ]+$/) - .withMessage('name is invalid') + .matches(/^[A-Za-z0-9 ]+$/) + .withMessage('name is invalid. Only letters, numbers, and spaces are allowed')If purely numeric names should be rejected, prefer
^(?=.*[A-Za-z])[A-Za-z0-9 ]+$here as well.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/validators/v1/organization.js(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/validators/**
⚙️ CodeRabbit configuration file
Validate all incoming data thoroughly. Check for missing or incomplete validation rules.
Files:
src/validators/v1/organization.js
🧠 Learnings (1)
📓 Common learnings
Learnt from: nevil-mathew
PR: ELEVATE-Project/user#811
File: src/validators/v1/admin.js:38-39
Timestamp: 2025-09-02T14:07:27.882Z
Learning: In src/validators/v1/admin.js, the username field validation intentionally accepts either a regular username pattern (a-z0-9_- with 3-40 chars) OR an email format pattern. This dual validation approach is by design, not an oversight.
🔇 Additional comments (1)
src/validators/v1/organization.js (1)
30-31: Enforce name length and clarify error messageIntroduce a length check before your regex and update the messages accordingly:
.withMessage('name field is empty') + .isLength({ min: 2, max: 100 }) + .withMessage('name must be 2-100 characters') .matches(/^[A-Za-z0-9 ]+$/) - .withMessage('name is invalid') + .withMessage('name is invalid. Only letters, numbers, and spaces are allowed')Optional: if purely numeric names should be disallowed, use
^(?=.*[A-Za-z])[A-Za-z0-9 ]+$. Verify these bounds against project conventions and ensure no downstream code depends on the old error text.
Summary by CodeRabbit