fix(admin): prevent negative values in organization size input#1640
fix(admin): prevent negative values in organization size input#1640paanSinghCoder wants to merge 2 commits into
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughSummary by CodeRabbit
WalkthroughTwo 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 ChangesOrganization Size Input Constraints
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
web/sdk/admin/views/organizations/details/edit/organization.tsx (1)
32-32: ⚡ Quick winConsider 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 winConsider 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
📒 Files selected for processing (2)
web/sdk/admin/views/organizations/details/edit/organization.tsxweb/sdk/admin/views/organizations/list/create.tsx
Coverage Report for CI Build 26220929180Coverage remained the same at 42.592%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Summary
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
-5in size, click Save — browser blocks submission.