fix(ack-pay): reject negative payment option decimals - #202
Conversation
Valibot paymentOptionSchema used toMinValue(0), which clamps negatives to 0 instead of rejecting them. Align with the Zod nonnegative() validator. Closes agentcommercekit#147
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. Walkthrough
ChangesPayment decimals validation
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to Payment options with negative decimal precision are now rejected rather than converted to zero, while valid decimal values remain accepted. The change aligns validation behavior across schema implementations and is ready to merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.)
✨ 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 |
Summary
paymentOptionSchema.decimalsusedv.toMinValue(0), which clamps negative values to0instead of rejecting them..nonnegative(), so the two schema implementations disagreed.v.minValue(0)and add parity tests covering accept/reject cases.Fixes #147
Test plan
pnpm --filter @agentcommercekit/ack-pay exec vitest run src/schemas/payment-option.test.tsdecimals: -1fails in both Valibot and Zoddecimals: 0 | 2 | 18still succeedsAI usage disclosure
AI-assisted with Cursor for repo navigation, the schema change, tests, and changeset. I reviewed and understand the Valibot
toMinValuevsminValuedistinction and that this aligns Valibot with the existing Zod validator.Summary by CodeRabbit
Bug Fixes
Tests