Interface ValidationInterceptor


@Contract public interface ValidationInterceptor
Interceptor for method validation processing. Allows to override the default Jersey behaviour. By default, the Jersey runtime throws a ValidationException or one of its subclasses, that gets mapped to a HTTP 400 response, if any validation issues occur. In such case the actual resource method does not get invoked at all.

Validation interceptor implementation allows to e.g. swallow the ConstraintViolationException and handle the validation issues in the resource method. It is also possible to tweak validated components. This could be utilized in case of proxied resources, when field validation is not possible on a dynamic proxy, and the validator requires the original delegated instance.

Each validation interceptor implementation must invoke proceed method on provided interceptor context as part of interception processing.

Since:
2.18
Author:
Jakub Podlesak
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Used to intercept resource method validation processing.
  • Method Details

    • onValidate

      void onValidate(ValidationInterceptorContext context) throws jakarta.validation.ValidationException
      Used to intercept resource method validation processing.

      To allow further validation processing, every and each implementation must invoke ValidationInterceptorContext.proceed() method.

      Parameters:
      context - method validation context.
      Throws:
      jakarta.validation.ValidationException - in case the validation exception should be thrown as a result of the validation processing.