Skip to content

feat: ISO 4217 currency validation (it.IsCurrency)#102

Merged
strider2038 merged 1 commit into
mainfrom
cursor/currency-constraint-iso4217-a6f1
Apr 17, 2026
Merged

feat: ISO 4217 currency validation (it.IsCurrency)#102
strider2038 merged 1 commit into
mainfrom
cursor/currency-constraint-iso4217-a6f1

Conversation

@strider2038
Copy link
Copy Markdown
Contributor

Adds Symfony-style Currency validation for ISO 4217 alphabetic codes.

Public API

  • it.IsCurrency() — string constraint (empty skipped; pair with it.IsNotBlank() when required).
  • validate.Currency(string) error — returns validate.ErrInvalidCurrency on failure.
  • is.Currency(string) bool.
  • validation.ErrInvalidCurrency / message.InvalidCurrency with English and Russian translations.

Implementation

Codes are validated with golang.org/x/text/currency.ParseISO (CLDR-backed set, no new go.mod entries). Letter case follows x/text rules (all upper or all lower; mixed case is rejected).

Tests & docs

  • Shared cases in test/constraints_identifiers_cases_test.go.
  • validate/currency_test.go, examples in it/example_test.go, validate/example_test.go, is/example_test.go.
  • CHANGELOG.md under [Unreleased] → Added.

Closes Linear IGO-33 (Currency ISO 4217).

Open in Web Open in Cursor 

Implement Currency constraint using golang.org/x/text/currency.ParseISO,
aligned with Symfony Currency. Add validate.Currency, is.Currency,
ErrInvalidCurrency, translations, tests, and examples.

Co-authored-by: Igor Lazarev <strider2038@yandex.ru>
@strider2038 strider2038 marked this pull request as ready for review April 17, 2026 18:14
@strider2038 strider2038 merged commit 51a89cd into main Apr 17, 2026
2 checks passed
@strider2038 strider2038 deleted the cursor/currency-constraint-iso4217-a6f1 branch April 17, 2026 18: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.

2 participants