Introducing validations in JAX-RS applications

Validation is the process of ensuring the completeness and sanity of business data before posting it to the underlying data source. Validating the client input is very important for any REST API that you build. In this section, we will see the offering in JAX-RS for validating client input.

The JAX-RS 2.x release allows you to validate the resource class and methods via Java Bean Validation. This framework is a Java specification, which lets you specify the validation rules on the objects or hierarchy of objects via the built-in annotations; it also lets you write the reusable validation rules for handling various use cases. Bean Validation is integrated into the Java EE platform, allowing developers to easily define and enforce the validation rules across various components that come as a part of Java EE. The following is a list of Java EE components that support Bean Validation: JAX-RS, JAXB, JPA, EJB, JSF, and CDI.

The latest release of Bean Validation is Version 2.0, which is based on JSR 380 and formerly JSR 349. You can learn more about JSR 380 at http://beanvalidation.org/2.0/spec/#introduction.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.75.217