Annotation Interface OneOf


@Retention(RUNTIME) @Target(FIELD) public @interface OneOf
Validates that a string field value is one of the specified options.
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The allowed values.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Whether to ignore case when matching.
    The error message.
    The suggestion shown after the error message describing how to fix it.
  • Element Details

    • value

      String[] value
      The allowed values.
      Returns:
      the allowed values
    • ignoreCase

      boolean ignoreCase
      Whether to ignore case when matching.
      Returns:
      true to ignore case
      Default:
      false
    • message

      String message
      The error message.
      Returns:
      the message
      Default:
      "Value must be one of: {value}"
    • suggestion

      String suggestion
      The suggestion shown after the error message describing how to fix it. Supports the same {...} placeholders as message() (substituted at validation time). Set to an empty string to omit the suggestion entirely.
      Returns:
      the suggestion template
      Default:
      "Use one of: {value}"