diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/web/BookController.java b/bookstore/src/main/java/com/fjordtek/bookstore/web/BookController.java index e8086be..9e6dc2d 100644 --- a/bookstore/src/main/java/com/fjordtek/bookstore/web/BookController.java +++ b/bookstore/src/main/java/com/fjordtek/bookstore/web/BookController.java @@ -204,7 +204,10 @@ public class BookController { HttpServletResponse responseData ) { - bookId = book.getId(); + // NOTE: We have a unique and non-nullable ISBN value for each book. + if (bookId != book.getId()) { + bindingResult.rejectValue("name", "error.user", "Wrong book"); + } if (bindingResult.hasErrors()) { responseData.setStatus(HttpServletResponse.SC_BAD_REQUEST);