Annotation Type LuhnCheck
@Documented
@Constraint(validatedBy={})
@Target({METHOD,FIELD,ANNOTATION_TYPE,CONSTRUCTOR,PARAMETER,TYPE_USE})
@Retention(RUNTIME)
@Repeatable(List.class)
public @interface LuhnCheck
Luhn algorithm check constraint.
Allows to validate that a series of digits pass the Luhn Modulo 10 checksum algorithm. The Luhn Mod10 is calculated by summing up the digits, with every odd digit (from right to left) value multiplied by 2, if the value is greater than 9 the the result digits a summed before the total summing.
The supported type is CharSequence
. null
is considered valid.
- Author:
- George Gastaldi, Hardy Ferentschik, Victor Rezende dos Santos
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interface
Defines several@LuhnCheck
annotations on the same element. -
Optional Element Summary
Optional Elements
-
Element Details
-
message
String message- Default:
- "{org.hibernate.validator.constraints.LuhnCheck.message}"
-
groups
Class<?>[] groups- Default:
- {}
-
payload
Class<? extends jakarta.validation.Payload>[] payload- Default:
- {}
-
startIndex
int startIndex- Returns:
- the start index (inclusive) for calculating the checksum. If not specified 0 is assumed.
- Default:
- 0
-
endIndex
int endIndex- Returns:
- the end index (inclusive) for calculating the checksum. If not specified the whole value is considered.
- Default:
- 2147483647
-
checkDigitIndex
int checkDigitIndex- Returns:
- The index of the check digit in the input. Per default it is assumed that the check digit is the last
digit of the specified range. If set, the digit at the specified index is used. If set
the following must hold true:
checkDigitIndex > 0 && (checkDigitIndex < startIndex || checkDigitIndex >= endIndex
.
- Default:
- -1
-
ignoreNonDigitCharacters
boolean ignoreNonDigitCharacters- Returns:
- Whether non-digit characters in the validated input should be ignored (
true
) or result in a validation error (false
).
- Default:
- true
-