Annotation Type EmptyIfOtherIsNotEmpty


@Documented @Constraint(validatedBy=EmptyIfOtherIsNotEmptyValidator.class) @Target({TYPE,ANNOTATION_TYPE}) @Retention(RUNTIME) public @interface EmptyIfOtherIsNotEmpty
The annotated bean must contain at least two properties:
  • a field that has to be checked (option field)
  • a field which entry is compared (option fieldCompare)
if the entry of fieldCompare is not empty (null or ""), field must be empty (null or "").
Supported types are beans, null elements are considered valid.
Author:
Manfred Tremmel
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static @interface 
    Defines several @MustBeEmptyIfOtherIsFilled annotations on the same element.
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    field name to check.
    field name to compare.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Class<?>[]
    groups to use.
    localized message.
    Class<? extends jakarta.validation.Payload>[]
    payload whatever.
  • Element Details

    • field

      String field
      field name to check.
      Returns:
      field/path of the value
    • fieldCompare

      String fieldCompare
      field name to compare.
      Returns:
      field/path of the value to compare
    • message

      String message
      localized message.
      Returns:
      localized validation message
      Default:
      "{de.knightsoftnet.validators.shared.EmptyIfOtherIsNotEmpty.message}"
    • groups

      Class<?>[] groups
      groups to use.
      Returns:
      array of validation groups
      Default:
      {}
    • payload

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