karlkauc opened a new pull request, #444:
URL: https://github.com/apache/commons-validator/pull/444

   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. `IBANCheckDigit` uses 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 values `00`, `01` and `99` are rejected, as the 
calculation can only produce `02`–`98`.
   - `LEIValidator`: validation of Legal Entity Identifiers (ISO 17442), built 
on `CodeValidator` with the regex `[A-Z0-9]{18}[0-9]{2}`, length 20 and the new 
check digit routine. Same structure as `ISINValidator` (singleton 
`getInstance()`, `isValid()`, `validate()`). Characters 5–6 are no longer 
required to be `00` since ISO 17442-1:2020, so this is not enforced.
   - Tests for both classes (`Modulus97CheckDigitTest` extends 
`AbstractCheckDigitTest`), a new section 4.6 "LEI validation" in 
`package-info.java`, and a `changes.xml` entry.
   
   ## 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 `CheckDigit` implementations 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 `Modulus97CheckDigit` proposed in #61: `calculate()` 
follows the `CheckDigit` contract and takes the code *without* check digits; 
the validator reuses `CodeValidator` instead of a custom wrapper; null is 
checked before trimming; Javadoc documents the standard and the test data 
sources.
   
   ## Testing
   
   - The default Maven goal (`mvn`: verify, apache-rat, japicmp, checkstyle, 
spotbugs, pmd, javadoc) passes with 3,314 tests.
   - Test LEIs come from public GLEIF data (https://search.gleif.org/, 
including GLEIF's own LEI `5493001KJTIIGC8Y1R12`), plus the ISO/IEC 7064 
example `794` → `79444` and the Leitweg-ID example `04011000-1234512345-06`.
   - The routine was additionally cross-checked against `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
   
   - ISO 17442 / LEI structure: 
https://www.gleif.org/en/about-lei/iso-17442-the-lei-code-structure
   - ISO/IEC 7064: https://en.wikipedia.org/wiki/ISO/IEC_7064


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to