Annotation Interface EmptyWhen


@PlacedAtClass @Target(TYPE) @Retention(RUNTIME) @Repeatable(EmptyWhen.EmptyWhenList.class) @Documented @Constraint(validatedBy=EmptyWhenValidator.class) public @interface EmptyWhen
Checks if specified propertyPath is empty only when condition is satisfied.
  • Element Details

    • propertyPath

      String[] propertyPath
      Is a validated field.

      Its name is propertyPath, not field because basically you set field names (like 'name'), but you can also set a field in a bean (like 'dept.name').

      The datatype is an array in order to validate multiple values at once.

      Returns:
      propertyPath
    • conditionPropertyPath

      String conditionPropertyPath
      Is a field, whose value determines whether the validation is executed or not.

      Its name is conditionPropertyPath, not conditionField because basically you set field names (like 'name'), but you can also set a field in a bean (like 'dept.name').

      Returns:
      conditionPropertyPath
    • conditionValue

      ConditionValue conditionValue
      Specifies a value used for determination whether validation is executed or not.

      ConditionValue has several types of values.

      Values which designate fixed values (such as EMPTY, TRUE, FALSE) means the same as empty (null for all datatypes and "" for String) and boolean true / false.
      Values such as STRING, PATTERN and VALUE_OF_PROPERTY_PATH does not directly express fixed values. So they need additional parameters to specify a variety of values.

      Returns:
      ConditionPattern
    • conditionOperator

      ConditionOperator conditionOperator
      Specifies the operator applied between the value of a condition field and the condition value To decide whether the condition is satisfied.
      Returns:
      ConditionOperator
      Default:
      EQUAL_TO
    • conditionValueString

      String[] conditionValueString
      Specifies condition value string.

      This is used when ConditionValue is STRING. Otherwise it must be unset.

      The condition is satisfied when ConditionOperator is EQUAL_TO and one of the values of this field is equal to the value of conditionPropertyPath.
      Otherwise when ConditionOperator is NOT_EQUAL_TO.

      You can use ConditionValue == STRING only when the datatype of conditionField is string. Otherwise you need to choose other choice.

      Returns:
      an array of string values
      Default:
      {"[null]"}
    • conditionValueRegexp

      String conditionValueRegexp
      Specifies condition regular expression.

      This is used when ConditionValue is PATTERN. Otherwise it must be unset.

      The condition is satisfied when ConditionOperator is EQUAL_TO and the value of conditionPropertyPath satisfies the regular expression.
      Otherwise when ConditionOperator is NOT_EQUAL_TO.

      You can use ConditionValue == Pattern only when the datatype of conditionField is string. Otherwise you need to choose other choice.

      Returns:
      regular expression
      Default:
      "[null]"
    • conditionValuePropertyPath

      String conditionValuePropertyPath
      Specifies condition value field.

      This is used when ConditionValue is VALUE_OF_PROPERTY_PATH. Otherwise it must be unset.

      The datatype of conditionValuePropertyPath can be the same as that of conditionPropertyPath, or its array. (Collection not supported)

      The condition is satisfied when ConditionOperator is EQUAL_TO and the value of conditionPropertyPath is equal to the value [one of values] of conditionValuePropertyPath.
      Otherwise when ConditionOperator is NOT_EQUAL_TO.

      Returns:
      an array of string values
      Default:
      "[null]"
    • displayStringOfConditionValue

      String displayStringOfConditionValue
      Specifies the the display string 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:
      ""
    • notEmptyWhenConditionNotSatisfied

      boolean notEmptyWhenConditionNotSatisfied
      Decides whether validation check is executed when the condition is not satisfied.
      Returns:
      boolean
      Default:
      false
    • message

      String message
      Returns message ID.
      Returns:
      message ID
      Default:
      "{jp.ecuacion.lib.validation.constraints.EmptyWhen.message}"
    • groups

      Class<?>[] groups
      Returns groups.
      Returns:
      groups
      Default:
      {}
    • payload

      Class<? extends jakarta.validation.Payload>[] payload
      Returns payload.
      Returns:
      payload
      Default:
      {}