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 implementation
From the course: Java EE: Bean Validation
Numerical constraints implementation
- [Instructor] Okay so now I'm going to open the transaction class, which we can open from the model package. This class represents a transaction in the stock, which might be either a buy or a sell instruction. And as you can see, it has the quantity filled which holds the number of stocks to be traded. Logically, this must be a positive value. So what I'm going to do is I'm going to use the positive bean validation constraint on this field. So here I'm just going to add our positive constraint, at positive. Further down, you can see that there is a price limit field, which is the maximum or minimum price the client wishes to trade stock. Now this field must be more than zero. So here I have a choice of which constraint to use. I can use the Min constraint and parse at the value zero. However, this constraint says that the value must be either zero or more. But I think that this constraint is a little bit too coarse-grained for my needs. I want to ensure that the price is not zero but…
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
-
-
-
-
-
-