Annotation 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
  • Element Details

    • message

      String message
      Default:
      "{org.hibernate.validator.constraints.UUID.message}"
    • groups

      Class<?>[] groups
      Default:
      {}
    • payload

      Class<? extends Payload>[] 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 UUIDs 00000000-0000-0000-0000-000000000000 are valid. Per default nil UUIDs are valid.
      Default:
      true
    • version

      int[] version
      Accepts values in the [1; 15] range, which corresponds to the hexadecimal [1; f] range.
      Returns:
      the accepted UUID version numbers. Per default, versions 1 through 5 are allowed.
      Default:
      {1, 2, 3, 4, 5}
    • variant

      int[] variant
      Accepts values in the [0; 2] range.

      The variant of the UUID is determined by the binary representation of the 17th hex digit (xxxxxxxx-xxxx-xxxx-Vxxx-xxxxxxxxxxxx where V is the variant digit).

      Currently, only variants [0, 1, 2] are supported by the validator:

      Table 1
      Variant # Binary Representation Hex Digit Comment
      0 0xxx 0 - 7
      1 10xx 8 - b
      2 110x c - d
      - 1110 e Unsupported, an UUID with such variant will be considered invalid.
      - 1111 f Unsupported, an UUID with such variant will be considered invalid.
      Returns:
      the allowed UUID variant numbers Per default, all 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