Skip to content

fix(admin): prevent negative values in organization size input#1640

Open
paanSinghCoder wants to merge 2 commits into
mainfrom
fix/admin-org-size-non-negative
Open

fix(admin): prevent negative values in organization size input#1640
paanSinghCoder wants to merge 2 commits into
mainfrom
fix/admin-org-size-non-negative

Conversation

@paanSinghCoder
Copy link
Copy Markdown
Contributor

@paanSinghCoder paanSinghCoder commented May 21, 2026

Summary

  • Add min={0} to the organization size number input in both the edit and create org side panels so the browser blocks negative submissions natively.

Test plan

  • Organisations → {id} → Edit: try entering / pasting -5 in size, click Save — browser blocks submission.
  • Organisations → Add new: same check on the create panel.

Add `min={0}` on the size number input in both the edit and create
organization side panels so the browser blocks negative submissions.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview, Comment May 21, 2026 10:39am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Organization size fields now properly prevent negative values in both the creation and editing forms.

Walkthrough

Two organization size input fields—one in the create organization form and one in the edit organization panel—now enforce a non-negative constraint by adding min={0} to the numeric input control.

Changes

Organization Size Input Constraints

Layer / File(s) Summary
Size input validation constraints
web/sdk/admin/views/organizations/details/edit/organization.tsx, web/sdk/admin/views/organizations/list/create.tsx
Both organization create and edit forms add min={0} constraint to size numeric inputs to prevent negative values.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

bug

Suggested reviewers

  • rsbh
  • rohilsurana
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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


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
Copy Markdown
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.

🧹 Nitpick comments (2)
web/sdk/admin/views/organizations/details/edit/organization.tsx (1)

32-32: ⚡ Quick win

Consider adding schema-level validation for non-negative size.

The HTML5 min={0} attribute provides good client-side validation, but the Zod schema should also validate that size is non-negative to ensure data integrity even if HTML5 validation is bypassed (e.g., via dev tools or programmatic form submission).

🛡️ Add schema validation for non-negative size
 const orgUpdateSchema = z
   .object({
     avatar: z.string().optional(),
     title: z.string(),
     name: z.string(),
-    size: z.string().transform((value) => parseInt(value)),
+    size: z.string().transform((value) => parseInt(value)).pipe(z.number().min(0, "Organization size cannot be negative")),
     type: z.string(),
     otherType: z.string().optional(),
     country: z.string(),
   })
web/sdk/admin/views/organizations/list/create.tsx (1)

30-30: ⚡ Quick win

Consider adding schema-level validation for non-negative size.

The HTML5 min={0} attribute provides good client-side validation, but the Zod schema should also validate that size is non-negative for defense-in-depth (same recommendation as in the edit form).

🛡️ Add schema validation for non-negative size
 const orgCreateSchema = z
   .object({
     avatar: z.string().optional(),
     title: z.string(),
     name: z.string(),
     orgOwnerEmail: z.string().email(),
-    size: z.string().transform((value) => parseInt(value)),
+    size: z.string().transform((value) => parseInt(value)).pipe(z.number().min(0, "Organization size cannot be negative")),
     type: z.string(),
     otherType: z.string().optional(),
     country: z.string(),
   })

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 46e1b154-52f9-48b6-9f0d-da8ad1b20762

📥 Commits

Reviewing files that changed from the base of the PR and between 98d6246 and 60dcd54.

📒 Files selected for processing (2)
  • web/sdk/admin/views/organizations/details/edit/organization.tsx
  • web/sdk/admin/views/organizations/list/create.tsx

@coveralls
Copy link
Copy Markdown

coveralls commented May 21, 2026

Coverage Report for CI Build 26220929180

Coverage remained the same at 42.592%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 37953
Covered Lines: 16165
Line Coverage: 42.59%
Coverage Strength: 11.91 hits per line

💛 - Coveralls

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