Annotation Interface AtLeastOneField


@Documented @Constraint(validatedBy=AtLeastOneFieldValidator.class) @Target(TYPE) @Retention(RUNTIME) public @interface AtLeastOneField
Validates that at least one of the specified fields has a non-blank value.
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The names of the fields to validate for at least one non-blank value.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Class<?>[]
    Validation groups to which this constraint belongs.
    The validation error message to display when none of the specified fields have values.
    Class<? extends jakarta.validation.Payload>[]
    Payload for clients to assign custom metadata to this constraint.
  • Element Details

    • message

      String message
      The validation error message to display when none of the specified fields have values.
      Returns:
      the error message
      Default:
      "At least one field must be provided"
    • groups

      Class<?>[] groups
      Validation groups to which this constraint belongs.
      Returns:
      the validation groups
      Default:
      {}
    • payload

      Class<? extends jakarta.validation.Payload>[] payload
      Payload for clients to assign custom metadata to this constraint.
      Returns:
      the payload
      Default:
      {}
    • fields

      String[] fields
      The names of the fields to validate for at least one non-blank value.
      Returns:
      the field names to check