Class ValidationViolation

java.lang.Object
org.apache.juneau.rest.server.validation.ValidationViolation

Wire-friendly snapshot of a single Jakarta Bean Validation constraint violation, suitable for inclusion in an HTTP error response body.

Produced by BeanValidator from a jakarta.validation.ConstraintViolation, with deliberately narrow surface so the bean is decoupled from the optional jakarta.validation runtime dependency. The invalidValue field is omitted by default to avoid echoing potentially sensitive request data back to the client; callers can opt back in via setInvalidValue(String).

JSON shape:

{ "path": "name", "message": "must not be blank", "constraint": "NotBlank" }

See Also:
Since:
10.0.0
  • Constructor Details

    • ValidationViolation

      Default constructor.
    • ValidationViolation

      public ValidationViolation(String path, String message, String constraint)
      Convenience constructor populating the three non-sensitive fields.
      Parameters:
      path - The property path string (e.g. "name" or "items[2].sku"). May be null.
      message - The localized violation message produced by the constraint validator. May be null.
      constraint - The simple name of the constraint annotation (e.g. "NotBlank"). May be null.
  • Method Details

    • getPath

      public String getPath()
      The Jakarta-Validation property path string — the dotted/indexed path from the validated root bean down to the violating field (e.g. "name" or "items[2].sku").
      Returns:
      The property path, or null if not set.
    • setPath

      Sets the property path.
      Parameters:
      value - The new value. Can be null to unset the property.
      Returns:
      This object.
    • getMessage

      public String getMessage()
      The localized violation message from the constraint validator (e.g. "must not be blank").
      Returns:
      The message, or null if not set.
    • setMessage

      Sets the message.
      Parameters:
      value - The new value. Can be null to unset the property.
      Returns:
      This object.
    • getConstraint

      The simple name of the constraint annotation that was violated (e.g. "NotBlank", "Size").
      Returns:
      The constraint name, or null if not set.
    • setConstraint

      Sets the constraint.
      Parameters:
      value - The new value. Can be null to unset the property.
      Returns:
      This object.
    • getInvalidValue

      The (string-rendered) invalid value that triggered the violation.

      Omitted by default to avoid echoing potentially sensitive request data back to the client; populated only when the caller explicitly opts in via setInvalidValue(String) (typically from a BeanValidator configured with includeInvalidValue(true)).

      Returns:
      The invalid value, or null if not set.
    • setInvalidValue

      Sets the invalid value.
      Parameters:
      value - The new value. Can be null to unset the property.
      Returns:
      This object.