Skip to content

feat(validation): add currency code enum for input validation#211

Merged
therealjhay merged 3 commits into
Betta-Pay:mainfrom
zinodict121:feat/currency-code-enum
Jul 1, 2026
Merged

feat(validation): add currency code enum for input validation#211
therealjhay merged 3 commits into
Betta-Pay:mainfrom
zinodict121:feat/currency-code-enum

Conversation

@zinodict121

@zinodict121 zinodict121 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Closes #89


Summary

Replaces plain z.string() validation on currency fields with a typed CurrencyCode enum, improving runtime error messages and enabling IDE autocompletion.

Changes

  • Defined CurrencyCode as z.enum(['USDC', 'EURT', 'NGN']) in shared/validation/currency.ts
  • Exported the CurrencyCode TypeScript type in shared/validation/index.ts
  • Updated CreatePaymentBody.asset to use CurrencyCode
  • Updated CreateSettlementBody.asset to use CurrencyCode
  • Updated FX quote schema from/to fields to use CurrencyCode
  • Note: Resolved existing git merge conflicts and strict-mode typing errors (latestLedgerCursor) in services/indexer/src/index.ts to restore a green testing baseline.

Why

Currency codes were previously validated as arbitrary strings, meaning invalid values like "USD" or "usd" would pass schema validation silently. The enum provides:

  • Strict validation with descriptive error messages
  • Full TypeScript type safety (CurrencyCode type)
  • IDE autocompletion on all currency fields
  • A single place to add new currencies in the future

Testing

  • All existing tests pass: pnpm test
  • TypeScript compiles without errors: pnpm -r type-check

Extensibility

To add a new currency, update the enum in shared/validation/currency.ts:

```ts
export const CurrencyCode = z.enum(['USDC', 'EURT', 'NGN', 'NEW_CURRENCY']);
```

No other changes are required.

Checklist

  • Code follows project conventions
  • No unrelated files changed (aside from resolving the broken baseline)
  • Tests pass
  • TypeScript compiles clean

CurrencyCode enum (USDC, EURT, NGN) replaces plain string validation
in asset/currency fields, providing better error messages and type safety.
@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@zinodict121 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

@therealjhay

Copy link
Copy Markdown
Contributor

Kindly resolve conflict

@zinodict121

Copy link
Copy Markdown
Contributor Author

Kindly resolve conflict

I have resolved the conflict

@therealjhay

Copy link
Copy Markdown
Contributor

Kindly resolve conflict

I have resolved the conflict

There are still conflicts

@therealjhay therealjhay merged commit 6e4988d into Betta-Pay:main Jul 1, 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.

Add currency code enum/union to validation schemas

3 participants