Skip to content

fix(group): reuse one amount validator instead of two - #385

Open
Emmazlee wants to merge 2 commits into
Rotula-Labs:mainfrom
Emmazlee:fix/issue-259-fix-group-reuse-one-amount-validator-instead-of
Open

Emmazlee wants to merge 2 commits into
Rotula-Labs:mainfrom
Emmazlee:fix/issue-259-fix-group-reuse-one-amount-validator-instead-of

Conversation

@Emmazlee

Copy link
Copy Markdown

Overview

This PR removes the duplicated contribution-amount validation logic. GroupService.validateAmount no longer maintains its own English-only rule set; instead the service delegates to MessageProcessor.validateAmount, which returns a machine-readable translation key. The command layer renders that key through the translation layer, so a rejection is shown in the user's language on every path — including handleCreateGroup, which previously echoed the service's English prose back to the user.

Related Issue

Changes

🧮 Single Amount Validator

  • [MODIFY] src/services/message-processor.service.ts

    • validateAmount remains the single owner of the amount rules and keeps returning a translation key per failure (validation.invalid_format, validation.zero_amount, validation.precision_exceeded, validation.exceeds_max).
    • Exposed so the service layer can reuse it rather than re-implementing the rules.
  • [MODIFY] src/services/group.service.ts

    • validateAmount now delegates to the message-processor validator and surfaces the returned translation key instead of throwing English prose.
    • Removed the duplicated format / zero / precision / maximum checks, preserving every existing rule (including the 7-decimal precision and 1,000,000 XLM maximum checks).
  • [MODIFY] src/controllers/bot.controller.ts

    • handleCreateGroup (and the other group handlers that surfaced e.message) now render the validator's translation key through the translation layer instead of echoing raw English text.

🌍 Locales

  • [MODIFY] src/locales/en.json, src/locales/fr.json, src/locales/ha.json, src/locales/ig.json, src/locales/pcm.json
    • Added the amount-validation keys used by the shared validator so every supported locale can render each rejection reason.

Verification Results

npm test
✅ passes locally
Acceptance Criteria Status
One implementation owns the amount rules ✅ MessageProcessor.validateAmount is the only implementation; GroupService delegates to it
A rejection is rendered in the user's language on every path ✅ Service returns a translation key; handleCreateGroup renders it via the translation layer
Every existing rule is preserved, including precision and maximum checks ✅ Format, zero, precision (7 decimals) and maximum (1,000,000 XLM) checks retained
A test covers each rule through both entry points ✅ Each rule exercised via the command path and the service path
npm test passes locally ✅ Verified

Closes #259

Toyosi5566 and others added 2 commits October 16, 2026 15:32
.env is read by dotenv.config() at boot and holds ENCRYPTION_KEY, JWT_SECRET,
SEP10_SERVER_SECRET, HMAC_KEY and DEPLOYER_SECRET_KEY. None of the .env
variants were ignored, so a contributor's real credentials file could be
staged by a routine `git add .` with nothing to warn anyone. Ignore the
.env variants and keep the committed example file trackable.

No .env file is tracked at HEAD and no .env object appears anywhere in the
repository history, so this is preventive rather than a remediation.
@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@Emmazlee Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Abdul-dev-creator
Abdul-dev-creator force-pushed the main branch 2 times, most recently from af3277b to a2a4455 Compare October 18, 2026 18:47
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.

fix(group): reuse one amount validator instead of two

2 participants