Skip to content

feat: Add ISIN validator#1570

Open
walle250ai wants to merge 1 commit into
go-playground:masterfrom
walle250ai:feat/isin-validator
Open

feat: Add ISIN validator#1570
walle250ai wants to merge 1 commit into
go-playground:masterfrom
walle250ai:feat/isin-validator

Conversation

@walle250ai
Copy link
Copy Markdown

Adds an isin struct tag validator for International Securities Identification Numbers (ISO 6166). Validation checks:

  1. Format: 2-letter country code + 9 alphanumeric chars + 1 check digit
  2. Luhn checksum: letters are expanded to their two-digit values (A=10 … Z=35) before applying the standard Luhn algorithm.
  • regexes.go: add isinRegexString and isinRegex
  • baked_in.go: register "isin" tag and implement isISIN()
  • validator_test.go: add TestISINStringValidation with valid ISINs (Apple, BP, BASF) and invalid cases (length, format, checksum, lowercase)

Fixes Or Enhances

Make sure that you've checked the boxes below before you submit PR:

  • Tests exist or have been written that cover this particular change.

@go-playground/validator-maintainers

Adds an `isin` struct tag validator for International Securities
Identification Numbers (ISO 6166). Validation checks:
1. Format: 2-letter country code + 9 alphanumeric chars + 1 check digit
2. Luhn checksum: letters are expanded to their two-digit values
   (A=10 … Z=35) before applying the standard Luhn algorithm.

- regexes.go: add isinRegexString and isinRegex
- baked_in.go: register "isin" tag and implement isISIN()
- validator_test.go: add TestISINStringValidation with valid ISINs
  (Apple, BP, BASF) and invalid cases (length, format, checksum,
  lowercase)
@walle250ai walle250ai requested a review from a team as a code owner April 28, 2026 08:05
Copy link
Copy Markdown
Member

@zemzale zemzale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.

The code looks good, but I would ask you to also update the docs before we can merge this.

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