Skip to content

fix(ack-pay): reject negative payment option decimals - #202

Closed
kutluhaneth46 wants to merge 1 commit into
agentcommercekit:mainfrom
kutluhaneth46:cursor/fix-ack-pay-decimals-minvalue-88c1
Closed

fix(ack-pay): reject negative payment option decimals#202
kutluhaneth46 wants to merge 1 commit into
agentcommercekit:mainfrom
kutluhaneth46:cursor/fix-ack-pay-decimals-minvalue-88c1

Conversation

@kutluhaneth46

@kutluhaneth46 kutluhaneth46 commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Valibot paymentOptionSchema.decimals used v.toMinValue(0), which clamps negative values to 0 instead of rejecting them.
  • Zod already uses .nonnegative(), so the two schema implementations disagreed.
  • Switch Valibot to 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.ts
  • Confirm decimals: -1 fails in both Valibot and Zod
  • Confirm decimals: 0 | 2 | 18 still succeeds

AI usage disclosure

AI-assisted with Cursor for repo navigation, the schema change, tests, and changeset. I reviewed and understand the Valibot toMinValue vs minValue distinction and that this aligns Valibot with the existing Zod validator.

Summary by CodeRabbit

  • Bug Fixes

    • Negative decimal values in payment options are now rejected instead of being silently changed to zero.
    • Decimal values must be non-negative whole numbers, with valid values such as 0, 2, and 18 accepted.
  • Tests

    • Added coverage for valid and invalid decimal values across supported validation formats.

Valibot paymentOptionSchema used toMinValue(0), which clamps negatives to 0
instead of rejecting them. Align with the Zod nonnegative() validator.

Closes agentcommercekit#147
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 70a32654-ee4c-40e4-bd86-2cf1431f5ce5

📥 Commits

Reviewing files that changed from the base of the PR and between 7d23f83 and 3676ecb.

📒 Files selected for processing (3)
  • .changeset/ack-pay-decimals-min-value.md
  • packages/ack-pay/src/schemas/payment-option.test.ts
  • packages/ack-pay/src/schemas/valibot.ts

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


Walkthrough

paymentOptionSchema now rejects negative decimals values instead of clamping them to zero. Tests cover valid and invalid values across the Valibot and Zod schemas. A patch changeset documents the fix.

Changes

Payment decimals validation

Layer / File(s) Summary
Reject invalid payment decimals
packages/ack-pay/src/schemas/valibot.ts, packages/ack-pay/src/schemas/payment-option.test.ts, .changeset/ack-pay-decimals-min-value.md
The Valibot schema uses v.minValue(0) for decimals. Tests verify accepted non-negative integers and rejected negative or fractional values. The changeset marks a patch release.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 3676e

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning 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 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the primary change: rejecting negative payment option decimals.
Linked Issues check ✅ Passed The PR replaces v.toMinValue(0) with v.minValue(0) in paymentOptionSchema and adds tests for rejection of negative decimals and acceptance of valid values. This satisfies issue #147.
Out of Scope Changes check ✅ Passed All changes support issue #147. The validator update, parity tests, and changeset are within scope.
Full details: Docstring Coverage

Explanation

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

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@venables

venables commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Thank you for the fix. This change is already open in #155, with earlier versions in #149 and #151. Closing as a duplicate of #155.

@venables venables closed this Sep 9, 2026
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.

bug: paymentOptionSchema.decimals uses toMinValue (clamps) instead of minValue (validates)

3 participants