Annotation Interface Word


@Documented @Retention(RUNTIME) @Constraint(validatedBy={}) @Target({PARAMETER,METHOD,FIELD}) @NotNull @NotBlank @Pattern(regexp="#\n# A single word\n# contains only Unicode letters and apostrophe (\') in the middle\n# only one apostrophe is allowed\n#\n^ # Start of the line\n( # Start of the group\n \\p{L} # Any Unicode letter\n| # OR\n (?<=\\p{L}) # Positive lookbehind for a Unicode letter\n \' # An apostrophe\n (?=\\p{L}) # Positive lookahead for a Unicode letter\n (?!.*\') # Negative lookahead for another apostrophe\n) # End of the group\n+ # One or more of the previous group\n$ # End of the line\n", flags={COMMENTS,CASE_INSENSITIVE}) public @interface Word
A single word.

A single word contains only Unicode letters and apostrophe (') in the middle. Only one apostrophe is allowed.

Examples:

  • word
  • it's
  • don't
  • can't
  • o'clock
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Class<?>[]
    The groups the constraint belongs to.
    The default error message if the validation fails.
    Class<? extends jakarta.validation.Payload>[]
    The payload that can be associated with a constraint violation.
  • Element Details

    • message

      String message
      The default error message if the validation fails.
      Returns:
      the error message
      Default:
      "must be a single word"
    • groups

      Class<?>[] groups
      The groups the constraint belongs to.
      Returns:
      the groups
      Default:
      {}
    • payload

      Class<? extends jakarta.validation.Payload>[] payload
      The payload that can be associated with a constraint violation.
      Returns:
      the payload
      Default:
      {}