Annotation Interface Pattern


@Target(FIELD) @Retention(RUNTIME) public @interface Pattern
Validates that a text config value - a String, or a char matched as a one-character string (since 6.3.0, #631) - matches the specified regular expression. If the value does not match, the module refuses to load naming the field and the pattern - the config file is never rewritten (D-01). The offending value itself is redacted from the refusal message when the field name looks secret-shaped (password/secret/token/credential/apikey).

On a value type it cannot check, the module is refused at load, before the file is read, naming the field and the annotation (since 6.3.0, #631; maintainer decision of 2026-10-06). So is this annotation on a field of a config class that is not a @ConfigEntry setting.

It takes effect only on a field that is itself a @ConfigEntry setting of a config class, judged by that field's declared type. A declared type that can hold a value the annotation checks - Object, Serializable, Comparable, CharSequence, Number or another supertype of a checked kind - is accepted, and the value bound at load is checked; only a type that can never hold a checkable value is a declaration error. A bound value of a kind the annotation cannot read (text under @Range, a number under @Pattern) is a violation like any other: the module is refused at load, and a reload is refused with the running values kept. On a field of a value type, a nested class or anything a converter produces it is never checked and not reported (maintainer decision of 2026-10-06): validate such fields in the module's converter.

See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The regular expression pattern to match against.
  • Element Details

    • regex

      String regex
      The regular expression pattern to match against.