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:
{
See Also:
- Since:
- 10.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.ValidationViolation(String path, String message, String constraint) Convenience constructor populating the three non-sensitive fields. -
Method Summary
Modifier and TypeMethodDescriptionThe simple name of the constraint annotation that was violated (e.g.The (string-rendered) invalid value that triggered the violation.The localized violation message from the constraint validator (e.g.getPath()The Jakarta-Validation property path string — the dotted/indexed path from the validated root bean down to the violating field (e.g.setConstraint(String value) Sets the constraint.setInvalidValue(String value) Sets the invalid value.setMessage(String value) Sets the message.Sets the property path.
-
Constructor Details
-
ValidationViolation
public ValidationViolation()Default constructor. -
ValidationViolation
Convenience constructor populating the three non-sensitive fields.- Parameters:
path- The property path string (e.g."name"or"items[2].sku"). May benull .message- The localized violation message produced by the constraint validator. May benull .constraint- The simple name of the constraint annotation (e.g."NotBlank"). May benull .
-
-
Method Details
-
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 benull to unset the property.- Returns:
- This object.
-
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 benull 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 benull 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 aBeanValidatorconfigured withincludeInvalidValue(true)).- Returns:
- The invalid value, or
null if not set.
-
setInvalidValue
Sets the invalid value.- Parameters:
value- The new value. Can benull to unset the property.- Returns:
- This object.
-