Description
The redaction policy schema names eleven validators for the custom identifier filter.
phileas/filters/identifier_validators/__init__.py registers eight: luhn, mod11, mod97,
mod23_letter, es_cif, de_steuerid, de_personalausweis and bic_structural. A policy naming
aba, verhoeff or damm raises at load, from resolve_validator in
phileas/filters/validators.py:90.
The spec describes them as:
| Validator |
Description |
aba |
ABA routing transit number checksum (weights 3-7-1 mod 10). |
verhoeff |
Verhoeff check digit (dihedral-group scheme). |
damm |
Damm check digit (quasigroup scheme). |
All three ports had this gap. philterd/phileas-dotnet#89 closes it for .NET and is a working
reference; philterd/phileas#391 tracks it for Java.
Notes from implementing it in .NET
The tables and the tests are language-independent, so most of the work transfers:
- Published vectors that exercise each scheme. Verhoeff accepts
2363, 123451 and 758722 and
rejects 12345. Damm accepts 5724 and 112946, rejects 5727 and 112949. ABA accepts
021000021.
- Two structural properties worth asserting, because a transcribed lookup table can be subtly
wrong and still look plausible. For any body exactly one appended digit may validate; and neither
scheme may accept a value with two adjacent digits transposed, which is the property that
distinguishes them from a plain modulus check. Assert both across a range of values, not on single
examples.
- ABA should require exactly nine digits and reject a tenth rather than letting the weights wrap.
Two things specific to this port:
\d is Unicode-aware here, as it is in .NET. re.fullmatch(r"\d{9}", "021000021")
matches, so a routing number written in fullwidth digits would pass a naive \d-based check. Use
[0-9], or re.ASCII. Java does not have this problem, so its implementation will not show it.
- The module docstring claims the validators "are parity ports: for the same input they return the
same result as the Java implementation." Java does not have these three yet
(philterd/phileas#391). If this lands first, that sentence needs qualifying rather than leaving a
claim that is no longer true.
Registration is a register_validator(name, factory) call in a new module under
phileas/filters/identifier_validators/, plus one import line in that package's __init__.py.
Acceptance criteria
Related
philterd/phileas-dotnet#89 closes the same gap for the .NET port, with a working implementation.
philterd/phileas#391 tracks it for Java.
Description
The redaction policy schema names eleven validators for the custom identifier filter.
phileas/filters/identifier_validators/__init__.pyregisters eight:luhn,mod11,mod97,mod23_letter,es_cif,de_steuerid,de_personalausweisandbic_structural. A policy namingaba,verhoeffordammraises at load, fromresolve_validatorinphileas/filters/validators.py:90.The spec describes them as:
abaverhoeffdammAll three ports had this gap.
philterd/phileas-dotnet#89closes it for .NET and is a workingreference;
philterd/phileas#391tracks it for Java.Notes from implementing it in .NET
The tables and the tests are language-independent, so most of the work transfers:
2363,123451and758722andrejects
12345. Damm accepts5724and112946, rejects5727and112949. ABA accepts021000021.wrong and still look plausible. For any body exactly one appended digit may validate; and neither
scheme may accept a value with two adjacent digits transposed, which is the property that
distinguishes them from a plain modulus check. Assert both across a range of values, not on single
examples.
Two things specific to this port:
\dis Unicode-aware here, as it is in .NET.re.fullmatch(r"\d{9}", "021000021")matches, so a routing number written in fullwidth digits would pass a naive
\d-based check. Use[0-9], orre.ASCII. Java does not have this problem, so its implementation will not show it.same result as the Java implementation." Java does not have these three yet
(
philterd/phileas#391). If this lands first, that sentence needs qualifying rather than leaving aclaim that is no longer true.
Registration is a
register_validator(name, factory)call in a new module underphileas/filters/identifier_validators/, plus one import line in that package's__init__.py.Acceptance criteria
aba,verhoeffanddammare implemented and registered, so a policy naming one loads.verhoeffanddamm.abarequires exactly nine digits, ignoring separators, and rejects both eight and ten.accepted.
shown to run during filtering rather than only to resolve by name.
parity claim in the package docstring is still accurate afterwards.
Related
philterd/phileas-dotnet#89closes the same gap for the .NET port, with a working implementation.philterd/phileas#391tracks it for Java.