Annotation Type Mod11Check
-
@Documented @Constraint(validatedBy={}) @Target({METHOD,FIELD,ANNOTATION_TYPE,CONSTRUCTOR,PARAMETER,TYPE_USE}) @Retention(RUNTIME) @Repeatable(List.class) public @interface Mod11Check
Modulo 11 check constraint.Allows to validate that a series of digits passes the Mod11 checksum algorithm. For the most common Mod11 variant the sum calculation is done by multiplying a weight from the rightmost digit (excluding the check digit) to the leftmost. The weight starts with 2 and increases by 1 for each digit. Then the result is used to calculate the check digit using
11 - ( sum % 11 ).Example: The check digit for 24187 is 3
Sum = 7x2 + 8x3 + 1x4 + 4x5 + 2x6 = 74
11 - (74 % 11) = 11 - 8 = 3, so "24187-3" is a valid character sequence.The Mod11 calculation can result in 10 or 11; per default 10 is treated as
'X'and 11 as'0', this behavior can be changed using the optionstreatCheck10AsandtreatCheck10As.Some implementations do the sum calculation in the reverse order (left to right); specify the processing direction
Mod11Check.ProcessingDirection.LEFT_TO_RIGHTin this case.The supported type is
CharSequence.nullis considered valid.- Author:
- George Gastaldi, Hardy Ferentschik, Victor Rezende dos Santos
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description intcheckDigitIndexintendIndexClass<?>[]groupsbooleanignoreNonDigitCharactersStringmessageClass<? extends Payload>[]payloadMod11Check.ProcessingDirectionprocessingDirectionintstartIndexintthresholdchartreatCheck10AschartreatCheck11As
-
-
-
Element Detail
-
message
String message
- Default:
- "{org.hibernate.validator.constraints.Mod11Check.message}"
-
-
-
groups
Class<?>[] groups
- Default:
- {}
-
-
-
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
-
-
-
processingDirection
Mod11Check.ProcessingDirection processingDirection
- Returns:
- Returns
RIGHT_TO_LEFTif the Mod11 checksum must be done from the rightmost to the leftmost digit. e.g. Code 12345-?:RIGHT_TO_LEFTthe sum (5*2 + 4*3 + 3*4 + 2*5 + 1*6) with check digit 5LEFT_TO_RIGHTthe sum (1*2 + 2*3 + 3*4 + 4*5 + 5*6) with check digit 7
RIGHT_TO_LEFTis assumed, it is the default Mod11 behavior.
- Default:
- org.hibernate.validator.constraints.Mod11Check.ProcessingDirection.RIGHT_TO_LEFT
-
-