@Retention(RUNTIME) @Target(FIELD) public @interface Size
Validates that a collection or string has a size within the specified range.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    int
    The maximum size.
    The error message.
    int
    The minimum size.
    An optional suggestion shown after the error message describing how to fix it.
  • Element Details

    • min

      int min
      The minimum size.
      Returns:
      the minimum size
      Default:
      0
    • max

      int max
      The maximum size.
      Returns:
      the maximum size
      Default:
      2147483647
    • message

      String message
      The error message.
      Returns:
      the message
      Default:
      "Size must be between {min} and {max}"
    • 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:
      ""