6.4.2. JAX-RS BeanValidation Handler

This handler executes Bean Validation for Form (Bean) received by the resource (action) class. If a validation error occurs during validation, the process is not delegated to the subsequent handler, and the process is ended after sending ApplicationException.

This handler performs the following process.

  • Performs Bean Validation for the form received by the resource (action) class method.

The process flow is as follows.

../../../../_images/flow16.png

6.4.2.2. Module list

<dependency>
  <groupId>com.nablarch.framework</groupId>
  <artifactId>nablarch-fw-jaxrs</artifactId>
</dependency>

<!-- Bean Validation module -->
<dependency>
  <groupId>com.nablarch.framework</groupId>
  <artifactId>nablarch-core-validation-ee</artifactId>
</dependency>

6.4.2.3. Constraints

Configure this handler after the Request Body Conversion Handler
Since this handler is for the validation of Form (Bean) converted from the request body by the Request Body Conversion Handler.

6.4.2.4. Execute validation for Form (Bean) received by resource (action)

To validate the Form (Bean) received by the resource (action) method, configure Valid annotation for that method.

An example is shown below.

// Since validation has to be performed on the Person object,
// configure a Valid annotation.
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Valid
public HttpResponse save(Person person) {
    UniversalDao.insert(person);
    return new HttpResponse();
}