Repository navigation
Conversation
… MOD 97-10) Add a generic check digit routine for the pure system ISO/IEC 7064, MOD 97-10 with the two numeric check digits at the end of the code, and an LEIValidator (Legal Entity Identifier, ISO 17442) built on CodeValidator with this routine, following the ISINValidator pattern. IBANCheckDigit uses the same algorithm, but IBAN check digits are at positions 3 and 4 and the code is rearranged first; Modulus97CheckDigit does not rearrange the code, so it can be used for all MOD 97-10 codes with trailing check digits (LEI, German Leitweg-ID, ...). The LEI validator checks format and check digits only; whether an LEI has been issued or is active is only known to GLEIF. Test data: LEIs from public GLEIF data (https://search.gleif.org/), the ISO/IEC 7064 example "794" -> "79444", and the Leitweg-ID example "04011000-1234512345-06". The check digit routine was cross-checked against IBANCheckDigit on 10,473 distinct real-world LEIs with identical results. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.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.
Jira: https://issues.apache.org/jira/browse/VALIDATOR-481
What
Modulus97CheckDigit: a generic check digit routine for the pure system ISO/IEC 7064, MOD 97-10 with the two numeric check digits at the end of the code.IBANCheckDigituses the same algorithm, but IBAN check digits sit at positions 3–4 and the code is rearranged first; this class does not rearrange anything, so it works for all MOD 97-10 codes with trailing check digits (LEI, German Leitweg-ID, …). Check values00,01and99are rejected, as the calculation can only produce02–98.LEIValidator: validation of Legal Entity Identifiers (ISO 17442), built onCodeValidatorwith the regex[A-Z0-9]{18}[0-9]{2}, length 20 and the new check digit routine. Same structure asISINValidator(singletongetInstance(),isValid(),validate()). Characters 5–6 are no longer required to be00since ISO 17442-1:2020, so this is not enforced.Modulus97CheckDigitTestextendsAbstractCheckDigitTest), a new section 4.6 "LEI validation" inpackage-info.java, and achanges.xmlentry.Why
Commons Validator has no LEI support. LEIs are mandatory identifiers in financial regulatory reporting (MiFID II, EMIR, Solvency II, FundsXML, …), and the check digit scheme is a well-defined ISO standard with a single authoritative source (GLEIF), comparable to IBAN and ISIN which are already covered.
Scope
This PR is intentionally small. It picks up the LEI part of the withdrawn #61 and follows the feedback in #271, where the maintainers said that generic, standardised
CheckDigitimplementations are welcome while country-specific validators with many moving parts are not. No Leitweg-ID or VAT validators are included; the Leitweg-ID example is only used as a test case to show the routine is not LEI-specific.Differences to the
Modulus97CheckDigitproposed in #61:calculate()follows theCheckDigitcontract and takes the code without check digits; the validator reusesCodeValidatorinstead of a custom wrapper; null is checked before trimming; Javadoc documents the standard and the test data sources.Testing
mvn: verify, apache-rat, japicmp, checkstyle, spotbugs, pmd, javadoc) passes with 3,314 tests.5493001KJTIIGC8Y1R12), plus the ISO/IEC 7064 example794→79444and the Leitweg-ID example04011000-1234512345-06.IBANCheckDigit(by moving the last four characters to the front) on 10,473 distinct real-world LEIs from FundsXML fund reports: identical results, 10,471 valid, 2 placeholders correctly rejected.References