🚀 Master the language of AI with our brand new course: "Prompt Engineering for Everyone" Learn more

Offered By: IBM

Validating constraints for JavaBeans in Java microservices

Explore the use of bean validation to validate user input data for microservices.

Continue reading

Guided Project

Open Liberty

4.2
(6 Reviews)

At a Glance

Explore the use of bean validation to validate user input data for microservices.

You will learn the basics of writing and testing a microservice that uses bean validation and the new functionality of Bean Validation 2.0. The service uses bean validation to validate that the supplied JavaBeans meet the defined constraints.
Bean Validation is a Java specification that simplifies data validation and error checking. Bean validation uses a standard way to validate data stored in JavaBeans. Validation can be performed manually or with integration with other specifications and frameworks, such as Contexts and Dependency Injection (CDI), Java Persistence API (JPA), or JavaServer Faces (JSF). To set rules on data, apply constraints by using annotations or XML configuration files. Bean validation provides both built-in constraints and the ability to create custom constraints. Bean validation allows for validation of both JavaBean fields and methods. For method-level validation, both the input parameters and return value can be validated.
Several additional built-in constraints are included in Bean Validation 2.0, which reduces the need for custom validation in common validation scenarios. Some of the new built-in constraints include @Email, @NotBlank, @Positive, and @Negative. Also in Bean Validation 2.0, you can now specify constraints on type parameters.
The example microservice uses both field-level and method-level validation as well as several of the built-in constraints and a custom constraint.

Estimated Effort

20 Minutes

Level

Intermediate

Skills You Will Learn

Java

Language

English

Course Code

GPXX0A1YEN

Tell Your Friends!

Saved this page to your clipboard!

Sign up to our newsletter

Stay connected with the latest industry news and knowledge!