Annotation Type NotEmptyIfOthersHaveValue


@Constraint(validatedBy=NotEmptyIfOthersHaveValueValidator.class) @Target({TYPE,ANNOTATION_TYPE}) @Retention(RUNTIME) public @interface NotEmptyIfOthersHaveValue
The annotated bean must contain at least two properties:
  • a field that has to be checked (option field)
  • a array of fields and entries to be compared (option otherFieldValueMapping)
if the entries of otherFieldValueMapping.fieldCompare matches one of the corresponding entries in otherFieldValueMapping.valueCompare (array of possible values), field must not be empty (null or "").
Supported types are beans, null elements are considered valid.
  • Nested Class Summary

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

    Required Elements
    Modifier and Type
    Required Element
    Description
    name of the field to be validated.
    array of FieldValueMapping's.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Class<?>[]
    validation groups.
    validation message.
    double
    optional minimum value that the field should have.
    Class<? extends jakarta.validation.Payload>[]
    payload classes.
  • Element Details

    • field

      String field
      name of the field to be validated.
      Returns:
      the name of the field to be validated
    • otherFieldValueMapping

      FieldValueMapping[] otherFieldValueMapping
      array of FieldValueMapping's.
      Returns:
      an array of FieldValueMapping's
    • message

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

      Class<?>[] groups
      validation groups.
      Returns:
      the validation groups
      Default:
      {}
    • minValue

      double minValue
      optional minimum value that the field should have.
      Returns:
      the minimum value that the field should have, -Double.MAX_VALUE if not specified.
      Default:
      -1.7976931348623157E308
    • payload

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