Class ValidationException

All Implemented Interfaces:
Serializable, HttpResponseMessage

public class ValidationException extends BadRequest
Specialization of BadRequest thrown by BeanValidator when one or more Jakarta Bean Validation constraints on a @Content, @FormData, or @Request-bound parameter are violated.

Behaves like a plain 400 Bad Request from the wire's perspective — same status code, same reason phrase, same default JSON envelope shape used by the rest of the framework's exception path — but adds a structured, serialized violations list so the response body can include the list of field-level errors that produced the failure.

Wire shape:

The response body depends on whether RFC 7807 problem-details mode is enabled on the resource:

  • Problem-details ON — application/problem+json with the standard status / title / detail members plus an errors[] extension array populated from getViolations().
  • Problem-details OFF (default) — application/json with a simple { "status":400, "errors":[ ... ] } envelope.
See Also:
Since:
10.0.0
See Also:
  • Field Details

  • Constructor Details

    • ValidationException

      Constructor.
      Parameters:
      violations - The list of constraint violations. Must not be null (use an empty list to signal "validation requested but no violations" — though that case never actually throws in practice).
    • ValidationException

      public ValidationException(List<ValidationViolation> violations, String msg, Object... args)
      Constructor with a custom detail message.
      Parameters:
      violations - The list of constraint violations. Must not be null.
      msg - The detail message. May be null. Treated as a format pattern when args is non-empty.
      args - Optional message arguments.
  • Method Details

    • getViolations

      Returns the immutable list of constraint violations that produced this exception.
      Returns:
      The list of violations, never null and never modifiable.
    • copyViolations

      Returns a defensive, mutable copy of the violation list for callers that need to inspect / filter it without mutating the exception's own state.
      Returns:
      A new mutable copy. Never null.