Skip to content

Conversation

@adithyadinesh0412
Copy link
Collaborator

@adithyadinesh0412 adithyadinesh0412 commented Sep 29, 2025

Summary by CodeRabbit

  • New Features
    • Organization names now support numeric characters in addition to letters and spaces for both creation and updates, allowing more flexible naming.
    • Validation behavior remains consistent with previous rules aside from the expanded character set; existing names are unaffected.
    • No changes to user-facing error messages or other flows.

@coderabbitai
Copy link

coderabbitai bot commented Sep 29, 2025

Walkthrough

Validation 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

Cohort / File(s) Summary
Organization name validation update
src/validators/v1/organization.js
Updated regex from /^[A-Za-z ]+$/ to /^[A-Za-z0-9 ]+$/ in create and update validators to allow numeric characters in organization names.

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I twitch my nose at regex gates,
Now digits dance through name-plates!
Hops of joy on validation green,
0-9 join the letter scene.
Thump-thump—forms pass with delight,
Bugs stay burrowed out of sight. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The title “@coderabbitai” does not describe any aspect of the changeset, which introduces numeric character support in organization name validation; it is unrelated and provides no context for reviewers. Please update the title to a concise, descriptive summary such as “Allow numeric characters in organization name validation” so reviewers can quickly understand the primary change.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

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.

❤️ Share

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

@coderabbitai coderabbitai bot changed the title @coderabbitai Allow digits in organization names for create/update in v1 validator Sep 29, 2025
Copy link

@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: 0

🧹 Nitpick comments (1)
src/validators/v1/organization.js (1)

50-51: Mirror the same constraints for update flow

Keep 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

📥 Commits

Reviewing files that changed from the base of the PR and between e391e82 and 3ee4c02.

📒 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 message

Introduce 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.

@nevil-mathew nevil-mathew merged commit 88c5f3a into ELEVATE-Project:develop Sep 29, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants