@Test public void checkLuhnTestForCard() { assertThat(ValiFieldCard.isLuhnTestValid(inputCard), is(true)); }
protected static boolean isLuhnTestValid(@NonNull String value) { int sum = 0; for (int i = value.length() - 1; i >= 0; i--) { int digit = Character.getNumericValue(value.charAt(i)) * POSITION_WEIGHT[(value.length() - i) % 2]; sum += digit > 9 ? (digit - 9) : digit; } return (sum % 10) == 0; }
ValiFieldCard extends ValiFieldLong { protected static boolean isLuhnTestValid(@NonNull String value) { int sum = 0; for (int i = value.length() - 1; i >= 0; i--) { int digit = Character.getNumericValue(value.charAt(i)) * POSITION_WEIGHT[(value.length() - i) % 2]; sum += digit > 9 ? (digit - 9) : digit; } return (sum % 10) == 0; } }
ValiFieldCard extends ValiFieldLong { protected static boolean isLuhnTestValid(@NonNull String value) { int sum = 0; for (int i = value.length() - 1; i >= 0; i--) { int digit = Character.getNumericValue(value.charAt(i)) * POSITION_WEIGHT[(value.length() - i) % 2]; sum += digit > 9 ? (digit - 9) : digit; } return (sum % 10) == 0; } ValiFieldCard();  ValiFieldCard(@Nullable Long defaultValue);  ValiFieldCard(@StringRes int errorResource);  ValiFieldCard(@Nullable Long defaultValue, @StringRes int errorResource);  ValiFieldCard(@Nullable Long defaultValue, String errorMessage); }
ValiFieldCard extends ValiFieldLong { protected static boolean isLuhnTestValid(@NonNull String value) { int sum = 0; for (int i = value.length() - 1; i >= 0; i--) { int digit = Character.getNumericValue(value.charAt(i)) * POSITION_WEIGHT[(value.length() - i) % 2]; sum += digit > 9 ? (digit - 9) : digit; } return (sum % 10) == 0; } ValiFieldCard();  ValiFieldCard(@Nullable Long defaultValue);  ValiFieldCard(@StringRes int errorResource);  ValiFieldCard(@Nullable Long defaultValue, @StringRes int errorResource);  ValiFieldCard(@Nullable Long defaultValue, String errorMessage);  }
ValiFieldCard extends ValiFieldLong { protected static boolean isLuhnTestValid(@NonNull String value) { int sum = 0; for (int i = value.length() - 1; i >= 0; i--) { int digit = Character.getNumericValue(value.charAt(i)) * POSITION_WEIGHT[(value.length() - i) % 2]; sum += digit > 9 ? (digit - 9) : digit; } return (sum % 10) == 0; } ValiFieldCard();  ValiFieldCard(@Nullable Long defaultValue);  ValiFieldCard(@StringRes int errorResource);  ValiFieldCard(@Nullable Long defaultValue, @StringRes int errorResource);  ValiFieldCard(@Nullable Long defaultValue, String errorMessage);   }