Skip to Content
Building RESTful Web Services with Java EE 8
book

Building RESTful Web Services with Java EE 8

by Mario-Leander Reimer
July 2018
Intermediate to advanced
116 pages
2h 41m
English
Packt Publishing
Content preview from Building RESTful Web Services with Java EE 8

Applying Design by Contract – adding validation

In this section, we're going to take a look at adding validation to the @PathParam annotation using Javax validation annotations. We will be adding validation POJOs and POST bodies using Javax validation annotations. I'm going to show you how to send the HTTP 404 status code for bad and invalid requests.

Let's switch to our IDE. As usual, we will prepare a small template project to get started. We create a BookResource similar to the one created in the previous Chapter 5, Using Server-Sent Events (SSEs). There's one thing missing though: there's nothing that tells the API that the ISBN is valid. Let's assume we wanted to add a validation for the ISBN and make sure that it's always 10-characters ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

RESTful Java Web Services - Third Edition

RESTful Java Web Services - Third Edition

Balachandar Bogunuva Mohanram

Publisher Resources

ISBN: 9781789532883Supplemental Content