@Documented @Repeatable(value: ValueOfEnumConstraintList) @Target(value: [FIELD, METHOD, PARAMETER, TYPE_USE, ANNOTATION_TYPE]) @Retention(value: RUNTIME) @jakarta.validation.Constraint(validatedBy: []) @interface ValueOfEnumConstraint
The annotated element must be a string representing a value of given enum (ignoring case).
Constraint accepts onlyString
types.
Annotation parameter enumClass
is mandatory, while enumNamesSubset
is optional.
When enumNamesSubset
is specified, provided string values must be names (ignoring case) from provided enumClass
.
In default validator implementation, default message interpolation keys (when message
annotation param is empty) are
org.klokwrk.lib.lo.validation.constraint.ValueOfEnumConstraint.invalidEnumValueMessage
and org.klokwrk.lib.lo.validation.constraint.ValueOfEnumConstraint.invalidSubsetOfEnumMessage
.
For custom message interpolation (when message
annotation param is configured), default implementation exposes enumClassSimpleName
and enumNamesSubsetList
expressions.
When custom annotation message
parameter value is specified, it can be either a reference to the resource bundle key (must be enclosed in curly braces '{}
'), or a hardcoded
message. In resource bundle and in the hardcoded message, exposed interpolation expressions must be enclosed in curly braces starting with a dollar sign '${}
'.
Type | Name and Description |
---|---|
static String |
INVALID_ENUM_VALUE_MESSAGE_KEY |
static String |
INVALID_SUBSET_OF_ENUM_VALUE_MESSAGE_KEY |