From the course: Jakarta Web Services

Unlock the full course today

Join today to access over 24,200 courses taught by industry experts.

Perform single field validations in REST

Perform single field validations in REST - Jakarta EE Tutorial

From the course: Jakarta Web Services

Perform single field validations in REST

- [Instructor] Now I'm going to show you how to use built-in constraints to perform single field validations in the travel application scenario. There's an endpoint in the travel app that retrieves a list of flights for a specific airline. The name of the airline should be given in the endpoint URL like this, if the caller sends a request to the endpoint without specifying the airline name as a query parameter, it comes back with an empty list which is not the expected behavior. Ideally, the endpoint parameter should be validated and a response should be returned indicating that the request was a bad or an invalid request. To do that, I can use the not-empty constraint to check if the query parameter is empty, by annotating the parameter with @NotEmpty and import it. Then if the query parameter is null or empty, this constraint will fail. Let's check that out. Now, when I send the request without specifying the…

Contents