Class VerhoeffCheckDigit

java.lang.Object
org.apache.commons.validator.routines.checkdigit.VerhoeffCheckDigit
All Implemented Interfaces:
Serializable, CheckDigit

public final class VerhoeffCheckDigit extends Object implements CheckDigit, Serializable
Verhoeff (Dihedral) Check Digit calculation/validation.

Check digit calculation for numeric codes using a Dihedral Group of order 10.

See Wikipedia - Verhoeff algorithm for more details.

Since:
1.4
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • calculate

      Calculate a Verhoeff Check Digit for a code.
      Specified by:
      calculate in interface CheckDigit
      Parameters:
      code - The code to calculate the Check Digit for
      Returns:
      The calculated Check Digit
      Throws:
      CheckDigitException - if an error occurs calculating the check digit for the specified code
    • isValid

      public boolean isValid(String code)
      Validate the Verhoeff Check Digit for a code.
      Specified by:
      isValid in interface CheckDigit
      Parameters:
      code - The code to validate
      Returns:
      true if the check digit is valid, otherwise false