The issue raises some interesting questions. The `passesMod11Test` tries to behave the same way as `mod10` which does the module calculation including the checksum digit and then you just have to verify whether the result is 0.
Theoretically you can do that with the mod 11 algorithm as well, but it would require a proper handling of the remainder. In the cases of a mod 11 remainder of 10 and 11 you need to use single-digit check digit/character. It seems 0 is often used for a remainder of 11 and another character (e.g. 'x') for a remainder of 10. This if not taken into account in @ModCheck. It only assumes numerical digits.
On top of this CPF chooses to use the same check digit for the case of a remainder of 10 and 11 (namely 0) which makes it even impossible to verify the number as we do currently.
I see how you patch fixes the problem, but it does not offer a solution for the case where a different character is used for the remainder of 10. Of course it does not have to, but I am just wondering what we have to do to make this work in a generic way.
|