Annotation Type UUID
@Documented
@Constraint(validatedBy={})
@Target({METHOD,FIELD,ANNOTATION_TYPE,CONSTRUCTOR,PARAMETER,TYPE_USE})
@Retention(RUNTIME)
@Repeatable(List.class)
public @interface UUID
Checks that the annotated character sequence is a valid
UUID.
Validation characteristics:
- Consists only of numbers, hex characters and dashes
- Has exact length of 36 characters
- Number of hex digits in every group (8-4-4-4-12)
- Nil UUID (default: allowed)
- Allowed UUID versions (default: 1 to 5)
- Allowed UUID variants (default: 0 to 2)
- Letter case (default: lower case)
The supported type is CharSequence
. null
is considered valid.
- Since:
- 8.0.0
- Author:
- Daniel Heid
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Required letter case for hex charactersstatic @interface
Defines several@UUID
annotations on the same element. -
Optional Element Summary
Modifier and TypeOptional ElementDescriptionboolean
boolean
Class<?>[]
int[]
Must not be lower than variant 0int[]
Must not be lower than version 1
-
Element Details
-
message
String message- Default:
- "{org.hibernate.validator.constraints.UUID.message}"
-
groups
Class<?>[] groups- Default:
- {}
-
payload
- Default:
- {}
-
allowEmpty
boolean allowEmpty- Returns:
- allow empty strings. Per default does not allow empty strings
- Default:
- false
-
allowNil
boolean allowNil- Returns:
true
if nil UUIDs00000000-0000-0000-0000-000000000000
are valid Per default nil UUIDs are valid
- Default:
- true
-
version
int[] versionMust not be lower than version 1- Returns:
- the accepted UUID version numbers Per default versions 1 to 5 are allowed
- Default:
- {1, 2, 3, 4, 5}
-
variant
int[] variantMust not be lower than variant 0- Returns:
- the allowed UUID variant numbers Per default variants 0 to 2 are allowed
- Default:
- {0, 1, 2}
-
letterCase
UUID.LetterCase letterCase- Returns:
- the required letter case Per default only lower case is valid
- See Also:
- Default:
- LOWER_CASE
-