@Repeatable(value=ValidationRules.class) @Target(value={ANNOTATION_TYPE,FIELD,METHOD,TYPE}) @Retention(value=RUNTIME) public @interface ValidationRule
| Modifier and Type | Required Element and Description |
|---|---|
String |
value
The validation rule.
|
| Modifier and Type | Optional Element and Description |
|---|---|
String |
fieldPath
The field path of the validation rule.
|
String |
message
The static message of the validation rule.
|
String |
messageExpression
The messageExpression of the validation rule.
|
boolean |
optionalOldSelf
The
optionalOldSelf field is a boolean field that alters the behavior of Transition Rules described below. |
String |
reason
The machine-readable validation failure reason.
|
public abstract String value
public abstract String message
If you want to set a static message, you can supply message rather than messageExpression().
The value of message is used as an opaque error string if validation fails
public abstract String messageExpression
Similar to the message() field, which defines the string reported for a validation rule failure,
messageExpression allows you to use a CEL expression to construct the message string.
public abstract String reason
The currently supported reasons are: "FieldValueInvalid", "FieldValueForbidden", "FieldValueRequired", "FieldValueDuplicate". If not set or for unknown reasons, it defaults to "FieldValueInvalid".
public abstract String fieldPath
Specifies the field to be returned when the validation fails.
public abstract boolean optionalOldSelf
optionalOldSelf field is a boolean field that alters the behavior of Transition Rules described below.
Normally, a transition rule will not evaluate if oldSelf cannot be determined: during object creation or
when a new value is introduced in an update.
If optionalOldSelf is set to true, then transition rules will always be evaluated and the type
of oldSelf will be changed to a CEL
Optional type.
The feature
CRDValidationRatcheting
must be enabled in order to make use of this field.Copyright © 2015–2024 Red Hat. All rights reserved.