Skip to content

fix(ack-pay): validate string payment amounts - #159

Open
Mabolla wants to merge 4 commits into
agentcommercekit:mainfrom
Mabolla:fix/validate-string-payment-amounts
Open

fix(ack-pay): validate string payment amounts#159
Mabolla wants to merge 4 commits into
agentcommercekit:mainfrom
Mabolla:fix/validate-string-payment-amounts

Conversation

@Mabolla

@Mabolla Mabolla commented Aug 14, 2026

Copy link
Copy Markdown

Summary

Tighten paymentOptionSchema.amount validation so string amounts follow the same positive-integer contract as numeric amounts.

Currently the numeric branch requires a positive integer, while the string branch accepts any string. This allows values such as "", "0", "-1", "1.5", and "abc" through schema validation even though payment amounts are expressed as integers in the smallest currency unit.

Changes

  • validate string amounts as positive integer strings in both Valibot and Zod schemas
  • keep string support for integers beyond JavaScript's safe integer range
  • add shared regression coverage for accepted and rejected values across both schema implementations
  • add an @agentcommercekit/ack-pay patch changeset

Validation

The regression tests cover positive numeric/string integers and reject zero, negative, fractional, empty, and non-numeric values in both schema implementations.

This is opened as a draft so the repository's PR checks can validate the full build/check workflow before marking it ready for review.

AI usage disclosure

This contribution was prepared with ChatGPT assistance for repository analysis, identifying the validation inconsistency, implementing the schema changes, and drafting regression tests. I reviewed the scope and can explain the behavior being changed: string payment amounts are restricted to decimal representations of positive integers, matching the existing numeric validation while retaining support for integer values too large to safely represent as JavaScript numbers.

Summary by CodeRabbit

  • Bug Fixes

    • Payment amounts now reject invalid values such as zero, negatives, fractions, empty strings, and nonnumeric text.
    • Large positive integer amounts provided as strings remain supported, including values beyond JavaScript’s safe integer range.
  • Tests

    • Added coverage to verify consistent validation across supported schema implementations.
  • Chores

    • Scheduled a patch release for the payment package.

@coderabbitai

coderabbitai Bot commented Aug 14, 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: Pro Plus

Run ID: bab0d1f2-6712-4b8b-969e-361dfd84c70a

📥 Commits

Reviewing files that changed from the base of the PR and between 0b8fdaa and 46b067c.

📒 Files selected for processing (4)
  • .changeset/clean-amount-strings.md
  • packages/ack-pay/src/schemas/payment-option.test.ts
  • packages/ack-pay/src/schemas/valibot.ts
  • packages/ack-pay/src/schemas/zod.ts

Walkthrough

The payment option schemas now restrict string amounts to positive integers. Valibot and Zod accept large positive integer strings and reject malformed, fractional, zero, negative, empty, and nonnumeric values. Tests cover both implementations, and a patch changeset records the update.

Changes

Payment amount validation

Layer / File(s) Summary
Restrict payment amount schemas
packages/ack-pay/src/schemas/valibot.ts, packages/ack-pay/src/schemas/zod.ts
Both schemas now accept positive integer numbers or strings matching /^[1-9]\d*$/.
Validate accepted and rejected amounts
packages/ack-pay/src/schemas/payment-option.test.ts, .changeset/clean-amount-strings.md
Tests compare Valibot and Zod results across valid and invalid amount inputs. The changeset records a patch release.

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

Merge Risk: ⚪ Minimal · up to 46b06

This localized change restricts string payment amounts to positive integer representations while preserving large-integer support; no actionable merge-blocking risk remains beyond normal checks and review.

Possibly related PRs

Suggested reviewers: venables

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: validating string payment amounts in ack-pay.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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.

@Mabolla
Mabolla marked this pull request as ready for review August 14, 2026 22:16
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.

1 participant