Annotation Interface Pattern


@Retention(RUNTIME) @Target(FIELD) public @interface Pattern
Validates that a string field matches a regular expression pattern.
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The regex pattern to match.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    int
    Pattern flags (from Pattern).
    The error message.
    An optional suggestion shown after the error message describing how to fix it.
  • Element Details

    • value

      String value
      The regex pattern to match.
      Returns:
      the pattern
    • flags

      int flags
      Pattern flags (from Pattern).
      Returns:
      the flags
      Default:
      0
    • message

      String message
      The error message.
      Returns:
      the message
      Default:
      "Value must match pattern: {value}"
    • suggestion

      String suggestion
      An optional suggestion shown after the error message describing how to fix it. Empty by default (no suggestion). When set, supports the same {...} placeholders as message().
      Returns:
      the suggestion template, or empty for none
      Default:
      ""