In this video, learn about the entire range of numerical constraints. These constraints ensure that numerical data meets the data constraint requirements you set. Additionally, meet limit constraints that restrict the limit of numerical values and size constraints that limit the size of data arrays and the length of fields. These constraints include: @Max, @Min, @DecimalMax, @DecimalMin, @Digits, @Negative, @NegativeOrZero, @Positive, @PositiveOrZero, and @Size.
- The range for numerical constraints provided out…of the box is quite extensive, and number 10.…They can be divided into three sub-categories.…Those that constrain on number boundaries,…those that constrain on a number sign,…and those that constrain on the size of a field.…Okay, so let's start looking at those that test boundaries.…Those that constrain on boundaries require…a maximum or minimum value to be specified.…That forms the conclusive limit.…There are five constraints in this category.…Let's have a look at some of these examples.…
The max annotation specifies a number that the value…of the field or property should not exceed.…It can be less than or equal to…the number past the annotation.…In this example, the value of the field must not exceed 100.…You can combine max and min to set…upper and lower boundaries.…And they only operate on integer numbers.…For decimal numbers, there are two alternative constraints…that do exactly the same job.…Decimal max and decimal min.…The digits annotation allows you to specify the maximum…
In this course, you can journey through the many constraints that are built into the 2.0 version of the Bean Validation API, as well as the additional constraints provided by the Hibernate Validator 6.0. Learn Bean Validation in a practical way while you build a functioning web application. Instructor Alex Theedom shows how to extend the API with custom constraints and how to internationalize validation failure messages. Plus, learn advanced techniques such as cross-field and cross-parameter validation, and how Bean Validation integrates with other Java EE technologies such as JAX-RS, Java Persistence API (JPA), and JavaServer Faces (JSF). By the end of this course, you will have gained practical experience of using Bean Validation in a real web application and be able to implement what you have learned in your own Java applications.
- What is Bean Validation?
- Applying the built-in constraints
- Applying Hibernate constraints
- Designing custom constraint validators
- Managing and configuring validation failure messages
- Creating custom composite constraints
- Creating custom validation constraints
- Cross-field and cross-parameter validation
- Integration with RESTful web services (JAX-RS)