Skip to content

Implement the aba, verhoeff, and damm identifier validators - #473

Merged
jzonthemtn merged 1 commit into
philterd:mainfrom
DG47:feat/aba-verhoeff-damm-validators
Nov 2, 2026
Merged

jzonthemtn merged 1 commit into
philterd:mainfrom
DG47:feat/aba-verhoeff-damm-validators

Conversation

@DG47

@DG47 DG47 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Fixes #391.

The redaction policy schema's validatorName enum and spec/v1.0/catalog/validators.yaml name eleven validators for the custom identifier filter, but IdentifierValidators implemented eight. A policy naming aba, verhoeff, or damm failed to load with Unsupported identifier validator.

Changes:

  • AbaValidator: the 3-7-1 weighted sum of the digits must be a multiple of 10. It requires exactly nine digits, ignoring separators, and returns false on a tenth digit rather than wrapping the weights.
  • VerhoeffValidator: Verhoeff check digit using the D5 multiplication table and the position permutation table, with the last digit as the check digit.
  • DammValidator: Damm check digit using the order-10 quasigroup table, with the last digit as the check digit.
  • All three ignore non-digit characters, like LuhnValidator, and follow the same singleton and isValid(String) shape. The tables match the ones in Implement the aba, verhoeff, and damm identifier validators phileas-dotnet#101.
  • IdentifierValidators resolves the three names, and the message on the default case lists all eleven.
  • identifier.md documents the three validators, and RELEASE_NOTES.md has an entry under 4.6.0.

Tests:

  • AbaValidatorTest: 021000021, 011000015, and 111000025 are accepted. Checksum failures, separators, eight digits, and ten digits (including a valid routing number followed by a tenth digit) are covered.

  • VerhoeffValidatorTest and DammValidatorTest: the published vectors from the issue (Verhoeff accepts 2363, 123451, 758722 and rejects 12345; Damm accepts 5724, 112946 and rejects 5727, 112949). There are also three property checks:

    • for every body from 0 to 99,999, exactly one appended digit validates
    • for every 6-digit value built from a 5-digit body and its check digit, swapping any two distinct adjacent digits is rejected
    • every single-digit substitution of a 5-digit valid value is rejected

    To confirm the property checks catch a bad table, I swapped two entries in one row of each table. The transposition check failed for both schemes.

  • IdentifierValidatorsTest: the three names resolve to their validators, and the unknown-name message lists all eleven.

  • IdentifierValidatorPolicyTest: for each validator, a JSON policy with a custom identifier and "validator": "<name>" goes through PlainTextFilterService. A value that passes the check is redacted, and a value of the same shape that fails it stays in the text.

Testing (JDK 17):

  • mvn --batch-mode test -Dtest='IdentifierValidatorsTest,AbaValidatorTest,VerhoeffValidatorTest,DammValidatorTest,IdentifierValidatorPolicyTest': Tests run: 67, Failures: 0, Errors: 0, Skipped: 0. With the IdentifierValidators change reverted, the resolution and policy tests fail with Unsupported identifier validator 'aba' (and likewise for verhoeff and damm).
  • mvn --batch-mode package: Tests run: 3230, Failures: 0, Errors: 0, Skipped: 0, BUILD SUCCESS

@DG47
DG47 requested a review from jzonthemtn as a code owner October 28, 2026 14:04
@sonarqubecloud

Copy link
Copy Markdown

@jzonthemtn

Copy link
Copy Markdown
Member

Thanks @DG47!

@jzonthemtn
jzonthemtn merged commit 9b805ab into philterd:main Nov 2, 2026
4 checks passed
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.

Implement the aba, verhoeff, and damm identifier validators

2 participants