O'Reilly logo

RESTful Java Patterns and Best Practices by Bhakti Mehta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Validating RESTful services

When exposing REST- or HTTP-based service APIs, it is important to validate that the API behaves correctly and that the exposed data format is structured in an expected manner. For example, it is important to validate an input to a RESTful service, such as e-mails sent as part of the request body, must conform to the standards, certain values in the payload must be present, the zip code must follow a particular format, and so on. This can be done by validations with RESTful services.

JAX-RS supports the Bean Validation to verify JAX-RS resource classes. This support consists of:

  • Adding constraint annotations to resource method parameters
  • Ensuring entity data is valid when the entity is passed in as a parameter

The following ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required