Module jp.ecuacion.lib.core
Annotation Interface ConditionalEmpty
@Target(TYPE)
@Retention(RUNTIME)
@Repeatable(ConditionalEmptyList.class)
@Documented
@Constraint(validatedBy=ConditionalEmptyValidator.class)
public @interface ConditionalEmpty
Checks if specified
field is empty
only when conditionField has specified value.
There are 4 ways to specify the value of conditionField.
conditionValue: You can set the specified value directly toconditionValueparameter. This can be used only when the datatype ofconditionFieldis String.conditionValueIsEmpty: You can settrueto this parameter means that the value ofconditionFieldis empty.conditionValueIsNotEmpty: You can settrueto this parameter means that the value ofconditionFieldis not empty.fieldHoldingConditionValue: You can set the field name to this parameter means that the value offieldHoldingConditionValueis the specified value.
(the datatype offieldHoldingConditionValueis always an array)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceDefines severalConditionalEmptyannotations on the same element. -
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionString[]Validation check is executed only when the valueconditionFieldholds is equal to to it.booleanValidation check is executed only when it's true and the valueconditionFieldholds is empty.booleanValidation check is executed only when it's true and the valueconditionFieldholds is not empty.Validation check is executed only when the value of the field specified by this parameter holds is equal to the value ofconditionField.Specifies a field which holds the display name of condition value.Class<?>[]Returns groups.Specifies class part (= left part) of item ID.Returns message ID.booleanDecides whether validation check is executed when the value ofconditionFieldis not equal to the specified value.Class<? extends jakarta.validation.Payload>[]Returns payload.
-
Element Details
-
field
String[] fieldValidated field.- Returns:
- field name
-
conditionField
String conditionFieldConditional field. Validation check is executed only when the value of this field is equal to the value whichfieldWhichHoldsConditionalValueholds.- Returns:
- condition field name
-
conditionValue
String[] conditionValueValidation check is executed only when the valueconditionFieldholds is equal to to it.You can use this value when the datatype of
conditionFieldisString. Otherwise you should usefieldWhichHoldsConditionalValue.Multiple values can be set to the parameter. In that case validation check is executed when one of the values are equal to the value of conditionField.
- Returns:
- value
- Default:
{"[null]"}
-
conditionValueIsEmpty
boolean conditionValueIsEmptyValidation check is executed only when it's true and the valueconditionFieldholds is empty.- Returns:
- boolean
- Default:
false
-
conditionValueIsNotEmpty
boolean conditionValueIsNotEmptyValidation check is executed only when it's true and the valueconditionFieldholds is not empty.- Returns:
- boolean
- Default:
false
-
fieldHoldingConditionValue
String fieldHoldingConditionValueValidation check is executed only when the value of the field specified by this parameter holds is equal to the value ofconditionField.- Returns:
- value
- Default:
"[null]"
-
notEmptyForOtherValues
boolean notEmptyForOtherValuesDecides whether validation check is executed when the value ofconditionFieldis not equal to the specified value.- Returns:
- boolean
- Default:
false
-
itemIdClass
String itemIdClassSpecifies class part (= left part) of item ID.- Returns:
- String
- Default:
""
-
fieldHoldingConditionValueDisplayName
String fieldHoldingConditionValueDisplayNameSpecifies a field which holds the display name of condition value.It can be an array datatype which has multiple values.
When the value is new String[] {""}, the condionValue specified is displayed as a part of an error message.- Returns:
- String
- Default:
""
-
message
String messageReturns message ID.- Returns:
- message ID
- Default:
"{jp.ecuacion.validation.constraints.ConditionalEmpty.message}"
-
groups
Class<?>[] groupsReturns groups.- Returns:
- groups
- Default:
{}
-
payload
Class<? extends jakarta.validation.Payload>[] payloadReturns payload.- Returns:
- payload
- Default:
{}
-