I have this method:
@GetMapping
public List<BudgetForecastApi> findByHotel(@PathVariable @Positive final int hotelCode,
@RequestParam(value = "includeDeleted", defaultValue = "false") final Boolean includeDeleted) {
return this.getService.findByHotel(hotelCode, includeDeleted);
}
and when I make an HTTP Request I get this error:
{ "id": "65dd4914-ddda-43c2-b204-b0a3e9279635", "code": "HTL-1", "date": "2023-11-16T14:59:30.44724275", "httpStatus": 400, "httpErrorMessage": "Bad Request", "message": "Service exception: Hotel configuration not found" }
But what I'm expecting is for the @Positive annotation to generate an error. And that only happens if I add a @Validated annotation at class level.
This is the error I get when I do that:
{ "id": "c2ad2ba6-c51f-4132-8394-fbacd40655d0", "code": "API-04", "date": "2023-11-16T15:13:50.57191511", "httpStatus": 400, "httpErrorMessage": "Bad Request", "message": "Validation error: hotelCode must be greater than 0, budgetForecastId must not be blank" }
What I am asking is why? why do I need @Validated? I didn't before. I'm confused and haven't found anything in the docs saying I'm required to use @Validated to trigger the rest of annotations.
Any input would be appreciated. Thank you.