You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
while reviewing the finance.py validators (ISIN, CUSIP, SEDOL), I found that the validators contain several issues, and I’d like to confirm whether this is a bug or if I’m missing something.
The official ISIN format is two uppercase letters, nine alphanumeric characters, and one check digit (12 characters total).
However, the current validator seems incomplete:
The Luhn checksum is implemented incorrectly and never computed.
The format is not enforced (first two characters should be uppercase letters, last must be a digit).
Lowercase letters and invalid characters are accepted.
It does not verify that the first two letters form a country code (optional, but usually expected).
I'm thinking of submitting a PR with a fix, but I'm asking first to make sure I'm not missing something.
Thanks!
Fixed by #464: isin() now validates the check digit (the previous implementation accepted any check digit). Lowercase input is still accepted, since the ISO 6166 test procedure uppercases ISINs before checking. Thanks for the report!
Activity
[-]Incorrect ISIN Validation Logic[/-][+]Incorrect finance Validation Logic[/+]nandgator commentedon Mar 9, 2026
Hi, thanks for reviewing the code. Please provider references for the claim. PRs are welcome.
nandgator commentedon Oct 10, 2026
Fixed by #464:
isin()now validates the check digit (the previous implementation accepted any check digit). Lowercase input is still accepted, since the ISO 6166 test procedure uppercases ISINs before checking. Thanks for the report!