Class LuhnUtils

java.lang.Object
org.instancio.internal.util.LuhnUtils

public final class LuhnUtils extends Object
  • Method Details

    • isLuhnValid

      public static boolean isLuhnValid(String s)
    • isLuhnValid

      public static boolean isLuhnValid(int startIdx, int endIdx, int checkIdx, String s)
      Check whether the given string conforms to the Luhn Modulo 10 checksum algorithm.

      See: Luhn algorithm.

      Parameters:
      startIdx - start index of the payload
      endIdx - end index of the payload
      checkIdx - index of the check digit
      s - to check
      Returns:
      true if the specified range of the string passes the Luhn check
    • getCheckDigit

      public static int getCheckDigit(char[] payload)