From the course: Java EE: Bean Validation
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Numerical constraints introduction
From the course: Java EE: Bean Validation
Numerical constraints introduction
- 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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Built-in constraints introduction5m 4s
-
(Locked)
Null constraints introduction2m 4s
-
(Locked)
Null constraints implementation5m 8s
-
(Locked)
Numerical constraints introduction2m 33s
-
(Locked)
Numerical constraints implementation6m 10s
-
(Locked)
Pattern, Boolean, and date constraints introduction2m 4s
-
(Locked)
Pattern, Boolean, and date constraints implementation6m 24s
-
-
-
-
-
-