Skip to content

Add IBAN validation constraint#93

Merged
strider2038 merged 4 commits into
mainfrom
cursor/-bc-e62609c4-def9-4060-92ba-c9980b5fd54d-526f
Apr 5, 2026
Merged

Add IBAN validation constraint#93
strider2038 merged 4 commits into
mainfrom
cursor/-bc-e62609c4-def9-4060-92ba-c9980b5fd54d-526f

Conversation

@strider2038
Copy link
Copy Markdown
Contributor

Summary

Adds International Bank Account Number (IBAN) validation aligned with Symfony's Iban / IbanValidator (country-specific patterns from Symfony 7.2, space/NBSP/NNBSP stripping, upper-case normalization, check digit range 02–98, mod-97 checksum).

Public API

  • it.IsIBAN() — string constraint (empty values skipped, same as other identifier constraints)
  • validate.IBAN(value string) error — returns validate.ErrInvalidIBAN on failure
  • is.IBAN(value string) bool
  • validation.ErrInvalidIBAN / message.InvalidIBAN with English and Russian translations

Files

  • validate/iban.go — validation logic
  • validate/iban_formats.go — generated regexp map from Symfony IbanValidator FORMATS

Testing

  • go test -race ./...
  • golangci-lint run (v2.11.4)
Open in Web Open in Cursor 

cursoragent and others added 3 commits April 4, 2026 19:43
- validate.IBAN with mod-97 check and Symfony 7.2 country patterns
- it.IsIBAN, is.IBAN, ErrInvalidIBAN, EN/RU messages
- Tests and examples; changelog entry

Co-authored-by: Igor Lazarev <strider2038@yandex.ru>
- Named subtests; valid samples for BE, AT, IT, SE
- Canonicalization: only spaces/NBSP, too short, bad UTF-8 prefixes
- Reject: non-alpha country, non-numeric check digits, BBAN vs pattern, tab

Co-authored-by: Igor Lazarev <strider2038@yandex.ru>
- Valid samples exercising Symfony regex branches (trailing letters, long BBAN)
- Negative: BR with correct length/pattern but failing mod-97; SC wrong total length; MU bank code width

Co-authored-by: Igor Lazarev <strider2038@yandex.ru>
… digits, mixed whitespace (#94)

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
@strider2038 strider2038 marked this pull request as ready for review April 5, 2026 05:15
@strider2038 strider2038 merged commit 3d160cc into main Apr 5, 2026
2 checks passed
@strider2038 strider2038 deleted the cursor/-bc-e62609c4-def9-4060-92ba-c9980b5fd54d-526f branch April 5, 2026 05:15
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