Add IBAN validation constraint#93
Merged
strider2038 merged 4 commits intoApr 5, 2026
Merged
Conversation
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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— returnsvalidate.ErrInvalidIBANon failureis.IBAN(value string) boolvalidation.ErrInvalidIBAN/message.InvalidIBANwith English and Russian translationsFiles
validate/iban.go— validation logicvalidate/iban_formats.go— generated regexp map from SymfonyIbanValidatorFORMATSTesting
go test -race ./...golangci-lint run(v2.11.4)