Uploaded image for project: 'Hibernate Validator'
  1. HV-901

Luhn Credit Card Validator incorrect return statement

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.1.0.Final, 5.1.1.Final
    • Fix Version/s: 5.1.2.Final, 5.2.0.Alpha1
    • Component/s: validators
    • Labels:
      None
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Sprint:

      Description

      The calculateLuhnMod10Check(final List<Integer> digits) method returns values 1 through 10 instead of 0 through 9. Since the check digit on the credit card can never be 10 and will sometimes be zero, all credit cards ending in zero, which are valid credit card numbers, are failing the validation. Example: 5105 1051 0510 5100.

      This is the portion of the validator we are using, but I believe this might also apply to the other two validations for mod 10 and mod 11 in the same ModUtil class, where an additional mod of the appropriate value will be needed to obtain the correct mod if the result is either 10 or 11.

      I am suggesting a change from the current return 10 - (sum % 10); to return (10 - sum % 10) %10;, in order to convert any result of 10 to zero, but still maintaining the integrity of all other possible results.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: